android - 媒体查询在 Android 上的行为不符合预期

标签 android css media-queries

我有 4 个媒体查询。第一个、第三个和第四个工作,但第二个似乎没有激活。

为什么 480x720(第二个媒体查询)默认为第一个媒体查询?

@media screen and (max-width: 320px) and (orientation: portrait) { body{background:#F0F;} }
@media screen and (min-width: 321px) and (max-width: 480px) and (orientation: portrait) { body{background:#F00;} }
@media screen and (max-width: 480px) and (orientation: landscape) { body{background:#0F0;} }
@media screen and (min-width: 481px) and (max-width: 800px) and (orientation: landscape) { body{background:#FF0;} }

预期的结果:

1st Media Query CSS Output 2nd Media Query CSS Output 3rd Media Query CSS Output 4th Media Query CSS Output

实际发生了什么:

2nd Media Query fails 1st Media Query passes 3rd Media Query passes 4th media query passes

为什么 480x720(第二个媒体查询)默认为第一个媒体查询?

最佳答案

我是 android 和 CSS 的新手。

我在我的 index.html 文件的标题中用一行解决了 android 不给它们真实大小的问题:

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

从那时起,我的 CSS 文件就如我所料!

关于android - 媒体查询在 Android 上的行为不符合预期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6047884/

相关文章:

css - Elm:加载时获取窗口宽度

html - 在 Codeigniter 上加载样式表

javascript - 如何在网页上进行多选题测试?

css - 在 Sass @for 循环中使用 css3 媒体查询

iphone - HTML5 Webapp 作为 iPhone 和 Android 上的常规图标或应用程序。

android - 在相对布局的元素之间划分屏幕宽度?

android - Android OpenGL ES 环境中的插值

javascript - 在手机上点击下拉菜单时使容器保持原位

css - 无论如何用CSS找出屏幕宽度

android - 我应该将 Android 应用程序的发布 key 存储提交到团队存储库吗?