微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

css – 如何使用媒体查询定位平板电脑而不是IE9

我发现IE9正在为我的网站采用平板电脑样式.
@media (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : portrait),(min-device-width : 768px) and (max-device-width : 1024px) and (orientation : landscape)
{
    /* tablet styles */
}

当浏览器的宽度为1024px时,上述媒体查询将应用于IE9.

做了一些研究之后,我发现了以下问题/解决方案,它提供了解释为什么会发生这种情况的原因.

Media query not working in IE9

From what I can tell,it comes down to IE9 not interpreting
“min-device-width” and “max-device-width”.

According to 07001 it does
not support those properties,only “min-width” and “max-width”.

In addition,07002
states that the browser is supposed to ignore properties that it does
not recognize. Not so with IE9 it seems.

我也发现了这个问题:Common breakpoints for media queries on a responsive site但它没有给我一个解决方案.

如何将样式表仅应用于平板电脑而不是IE9等桌面浏览器,宽度为1024px?

解决方法

您需要在< head>中添加此元标记你的文件
<Meta name="viewport" content="width=device-width,initial-scale=1.0">

然后在你的CSS中你可以替换:

> min-device-width with min-width> max-device-width with max-width.

原文地址:https://www.jb51.cc/css/215740.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。