【发布时间】:2016-09-02 18:18:33
【问题描述】:
我注意到更改设备方向(Android 手机)会导致 screen.width 发生更改。例如,在我的华为安卓手机上,在纵向位置screen.width == 360 像素,而在横向 640 像素。考虑到(至少据我所知)screen.width 拥有device-width 属性值,为什么下面的代码:
@media screen and (max-device-width:360px){
div {
background-color: green;
}
}
@media screen and (min-device-width:361px){
div {
background-color: blue;
}
}
不工作?
如果device-width 与screen.width 链接,它的值不应该像screen.width 那样随着实际设备方向而改变吗?
【问题讨论】:
-
jsbin.com/kusikelejo/edit?html,css,output 什么不起作用?似乎工作正常。尝试调整输出帧的大小。
-
我不打扰桌面。正如我所写的,我正在移动 android 手机上测试代码。在上述
device-width的解决方案中不起作用 - 背景颜色不会随着设备方向的变化而变化。 -
我刚刚使用 chrome 应用检查了手机上的 jsbin 链接。它正在以某种方式改变-