css - 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
解决方案
是的,可以通过js代码检测屏幕大小并加载合适的内容
screen.height;
screen.width;
推荐阅读
- javascript - javascript块背后的魔力是什么?
- java - Java:JFrame图像仅在最大化窗口时出现
- python - 如何使用 pymongo 迭代带有嵌入式文档的 mongo 文档?
- postgresql - 如何使用 jdbc 为 postgresql 的位列插入值
- python - LeetCode 700. 在二叉搜索树中搜索
- java - 范围在 for 循环之外的变量自动将值更改为 0
- php - PHP连接数据库得到错误连接错误:SQLSTATE [HY000] [2002] php_network_getaddresses
- javascript - 状态为空,甚至设置了数据
- node.js - Node.js 服务器和 Mongoose 连接不起作用
- machine-learning - 使用 cross_val_score() 的正确方法是什么