【问题标题】:css-tricks.com media query just not workingcss-tricks.com 媒体查询不起作用
【发布时间】:2016-01-30 23:58:33
【问题描述】:

是否有一些使用媒体查询的新标准。或者我应该说,应该做出一些新的考虑。

CSS tricks article 似乎不太好用,因为“智能手机领域”似乎劫持了一切。

我直接使用的代码(除了打印屏幕应该是什么:

/* Smartphones (portrait and landscape) ----------- */
@media only screen 
and (min-device-width : 320px) 
and (max-device-width : 480px) {
.size:after{ content: "smartphone portrait and landscape";}
body{background-color:#111; color:#fff;}
}

/* Smartphones (landscape) ----------- */
@media only screen 
and (min-width : 321px) {
.size:after{ content: "smartphone landscape";}
body{background-color:#222; color:#fff;}
}

/* Smartphones (portrait) ----------- */
@media only screen 
and (max-width : 320px) {
.size:after{ content: "smartphones portrait";}
body{background-color:#333; color:#fff;}
}

/* iPads (portrait and landscape) ----------- */
@media only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) {
.size:after{ content: "ipad protrait and landscape";}
body{background-color:#444; color:#fff;}
}

/* iPads (landscape) ----------- */
@media only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) 
and (orientation : landscape) {
.size:after{ content: "ipad landscape";}
body{background-color:#555; color:#fff;}
}

/* iPads (portrait) ----------- */
@media only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) 
and (orientation : portrait) {
.size:after{ content: "iPads portrait";}
body{background-color:#666; color:#000;}
}

/* Desktops and laptops ----------- */
@media only screen 
and (min-width : 1224px) {
.size:after{ content: "desktops and laptops";}
body{background-color:#777; color:#000;}
}

/* Large screens ----------- */
@media only screen 
and (min-width : 1824px) {
.size:after{ content: "largscreens";}
body{background-color:#888; color:#000;}
}

/* iPhone 4 ----------- */
@media
only screen and (-webkit-min-device-pixel-ratio : 1.5),
only screen and (min-device-pixel-ratio : 1.5) {
.size:after{ content: "iPhone 4";}
body{background-color:#999; color:#000;}
}

测试:www2.iscotest.com/screen.php

是否只有宽屏、桌面 (1024)、ipad 横向、ipad 纵向、移动纵向和移动横向的工作标准集。

谢谢!

【问题讨论】:

    标签: css media-queries


    【解决方案1】:

    只使用最小宽度和最大宽度

    【讨论】:

      【解决方案2】:

      您的链接没有显示,您是否添加了 css 元信息?

      <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
      

      【讨论】:

      • 是的,那个模拟器显然有点不合作。只需更改实际站点 www2.iscotest.com/screen.php 上的窗口大小可能会更有帮助
      猜你喜欢
      • 2013-05-30
      • 1970-01-01
      • 2023-03-09
      • 2013-08-14
      • 2015-09-06
      • 2013-03-12
      • 2013-03-01
      • 2021-12-08
      相关资源
      最近更新 更多