首页 > 解决方案 > Apply different layouts to the site for different window size?

问题描述

I know we can use media query to change the css for different sizes.

My question is: is it possible to change to a totally new page layout (or View in MVC) when window size, say when width < 500? Assume the controller is the same.

Kind of like: get the window size in the view, then decide what layout to use.

I know this is not a good way, but is it possible?

Thanks

标签: cssasp.net-mvc

解决方案


是的,可以通过js代码检测屏幕大小并加载合适的内容

screen.height;
screen.width;

推荐阅读