【问题标题】:Media Queries failing on Android browserAndroid 浏览器上的媒体查询失败
【发布时间】:2011-09-12 09:40:33
【问题描述】:

我正在尝试开发一个网络应用程序,该应用程序根据设备(及其方向)应用适当的样式表。

我总共有 5 个媒体查询:

//for mobile phones in portrait mode
<link rel="stylesheet" media="all and (max-device-width: 480px) and (orientation:portrait)" href="css/mobile-portrait.css">

//for mobile phones in landscape mode
<link rel="stylesheet" media="all and (max-device-width: 480px) and (orientation:landscape)" href="css/mobile-landscape.css">

//for tablets (iPad) in portrait mode
<link rel="stylesheet" media="all and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:portrait)" href="css/tablet-portrait.css">

//for tablets (iPad) in landscape mode
<link rel="stylesheet" media="all and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:landscape)" href="css/tablet-landscape.css">

//for desktop computers
<link rel="stylesheet" media="all and (min-device-width: 1025px)" href="css/desktop.css">  

在桌面、iPad 和 iPhone 上一切正常(浏览器和网络应用程序版本)但横向媒体查询在 Android 浏览器上失败?有任何想法吗?我把“最大设备宽度”弄错了吗?

【问题讨论】:

标签: iphone android web-applications media-queries iphone-web-app


【解决方案1】:

在 Droid1 上 - 视口大小为 320 x 569。

【讨论】:

    【解决方案2】:

    这是因为大多数较新的 android 手机大约是 480 宽 x 800 高,具体取决于设备,所以按照您编写的方式,Android Landscape 应该被平板电脑景观 css 采用。但我想我遇到了类似的问题,Android 没有选择样式表,所以我添加了这个,一切似乎都正常......

    <meta name="viewport" content="width=device-width"> 
    

    在你的样式表链接上方你有这个想法吗?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-04-02
      • 2014-12-08
      • 1970-01-01
      • 2014-05-20
      • 2014-10-01
      • 2016-10-14
      • 2016-06-01
      • 1970-01-01
      相关资源
      最近更新 更多