繁体   English   中英

IE9-11 @media冲突

[英]IE9-11 @media Conflicts

我最近在IE中遇到了背景图片和媒体查询的问题。 在我看来,IE9和10与媒体查询的background属性冲突,导致没有图像出现。 在IE11中,仅显示“移动”图像。 我在这里待了大约2天,完全被困住了。

我为IE9找到的唯一解决方案是创建条件语句并使用!important。 不幸的是,这在10和11中不起作用(谢谢Microsoft)。 任何帮助表示赞赏。 同时,我将继续进行研究。

请记住,我仅通过netrenderer.com对此进行了测试,因此我不确定100%是否正确。

HTML:

<div style="width: 100%; border: 1px solid #00F;">
    <div class="logo"></div>
</div>

CSS:

    .logo { width: 500px; height: 190px; background: url(desktop.png) no-repeat; }
    @media ( max-width: 400px ) {
        .logo { width: 100%; height: 140px; background: url(mobile.png) no-repeat; }
    }

我在IE11及其针对IE10和9的模式测试了以下代码 。它工作正常。

.logo { width: 500px; height: 190px; background: url(http://placehold.it/600x300) no-repeat; }
@media screen and ( max-width: 400px ) {
    .logo { width: 100%; height: 140px; background: url(http://placehold.it/350x150) no-repeat; }
}

您忘记在媒体查询中添加screen

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM