如何编写CSS媒体查询,应该只适用于IE9和IE 10?

时间:2016-09-28 14:14:42

标签: css internet-explorer internet-explorer-9 internet-explorer-10

目前我正在使用的CSS类是:

body.srp-map-view {
  .page-content {
    position: absolute;
    top: 49px; 
    right: 0;
    left: 0;
    bottom: 0;
    overflow-x: hidden;
  }
}

如果是IE 9或IE 10,我必须添加margin-top:29px;以上的财产。

我尝试了一些我在stackoverflow中找到的媒体查询,但它们无法正常工作。除了媒体查询之外,还有其他方法可以写吗?

2 个答案:

答案 0 :(得分:0)

尝试使用IE条件语句...

<!--[if gte IE 6]>
    <link rel="stylesheet" type="text/css" href="ie6-and-up.css" />
<![endif]-->    

这可能很有用..

https://css-tricks.com/how-to-create-an-ie-only-stylesheet/

答案 1 :(得分:0)

此处描述的方法适用于IE10及以上版本,不再支持条件评论:

https://css-tricks.com/ie-10-specific-styles/

正如文章所说,如果可能的话,你最好使用功能检测而不是浏览器检测。