1

我正在尝试根据屏幕宽度设置元素的宽度。除了 Galaxy Note 2,我的代码在台式机和大多数移动设备上都能完美运行。我试过这个查询,但无济于事

@media only screen and (max-width: 480px), only screen and (max-device-width: 480px), only screen and (-webkit-min-device-pixel-ratio : 1.5),
only screen and (min-device-pixel-ratio : 1.5) {
    // my css here
}
4

2 回答 2

1

Galaxy Note II会在旋转过程中切换innerHeight和Screen.height。下面列出了 innerHeight/Width 和 Screen.Height/Width

Portrait  innerHeight/Screen.Height 615/1280
          innerWidth/Screen.Width   360/720
Landscape innerHeight/Screen.Height 335/720
          innerWidth/Screen.Width   640/1280

根据这篇文章 http://tripleodeon.com/2011/12/first-understand-your-screen/ 媒体查询 min/max-device-height/width 等于 screen.height/width 所以对于 Galaxy Note II,我的媒体查询在下面列出

/*  Galaxy Note2 - Portrait */
@media only screen and (-webkit-min-device-pixel-ratio: 2) and (min-device-height: 1200px) and (max-device-height: 1300px) and (orientation: portrait) {
    Code here
}

/*  Galaxy Note2 - landscape Due to the Screen Height and Width is changing during orientation changes */
@media only screen and (-webkit-min-device-pixel-ratio: 2) and (min-device-width: 1270px) and (max-device-width: 1300px) and (orientation: landscape) {
    Code here
}
于 2013-11-13T17:36:58.317 回答
0

您可以使用条件样式表仅针对该电话。这有点像用大锤修复凹痕,但它起作用。您可以解析用户代理字符串并为该手机型号添加样式表。

于 2013-08-13T18:32:45.927 回答