IE条件CSS即将推出FF&铬

时间:2016-08-30 07:01:10

标签: html css css3 internet-explorer

我使用简单的方法来定位IE只有CSS。

   <!--[if !IE]><!-->
       <body>
    <!--<![endif]-->
    <!--[if IE]>
       <body class="ie">
    <![endif]-->


<div class="Out">My test content
</div>

外部CSS

.Out{
 width:300px;/*Not for IE*/
}
ie. Out{
 width:300px; /*only for IE*/
}

但在FF&amp; chrome developer工具我看到body class="ie"这是错误的。class="ie"仅适用于IE浏览器。

我提到的数字文章

参考:

https://css-tricks.com/snippets/html/add-body-class-just-for-ie/

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

Detecting IE11 using CSS Capability/Feature Detection enter link description here

http://www.positioniseverything.net/articles/cc-plus.html .....等列表继续

我已经提到了一些文章而没有帮助。我想我错过了一些东西。

1 个答案:

答案 0 :(得分:0)

我在我的问题中提到过各种来源和文章中的很多东西。

幸运的是,从"SW4" in how-to-write-a-css-hack-for-ie-11

回答我的工作

IE 8,9和10

.Out {
       width:400px\0; /*For IE 8,9 and 10.*/
       /* For me above code is also supporting in IE 11 also. However, for IE 10+ browser I have added media query using -ms-high-contrast below*/

      width: 300px;   /*for other Browsers*/
         }

这是一种非常简单的技术:使用-ms-high-contrast创建媒体查询,在其中放置IE 10和11特定的CSS样式。因为-ms-high-contrast是特定于Microsoft的(并且仅在IE 10+中可用),所以它只能在Internet Explorer 10及更高版本中进行解析。

-ms-high-contrast支持两个值:none和active。因此,无论属性设置如何,要定位IE10 +,请使用此媒体查询:

@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
width:400px; /* IE10+ CSS styles go here */
}