仅为IE11加载css(样式表)

时间:2014-12-30 10:12:20

标签: html css stylesheet internet-explorer-11 conditional-comments

我想仅为IE11浏览器加载css文件。我该怎么办?

我知道我可以使用conditional comments为IE< = 9加载样式表。但不适用于IE 10& 11.

我可以在Google上找到替代方案,如下所示:

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

但是,它加载了IE10和IE11浏览器。我想为IE11加载样式表 。有可能吗?

由于

2 个答案:

答案 0 :(得分:16)

如果它只是IE11

@media all and (-ms-high-contrast:none)
 {
 .foo { color: green } /* IE10 */
 *::-ms-backdrop, .foo { color: red } /* IE11 */
 }

如果你的目标是IE 9,10,11,你可以尝试

@media screen and (min-width:0\0) { 
    /* Enter CSS here */
}

如果适用于IE10 +

@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {  
   /* IE10+ specific styles go here */  
}

此外,google search想出了这个

_:-ms-fullscreen, :root .ie11up { property:value; }

答案 1 :(得分:0)

你可以使用jquery尝试这个你可以添加类到body并添加你的css通常它只需要类,当它即11

if ($.browser.msie && $.browser.version <= 11) {
 $("body").addClass("ie10");
}
相关问题