如何指定IE 11特定的css文件?

Sac*_* R. 3 html css internet-explorer internet-explorer-11

我目前有一个页面,当用户使用以下html语法单击打印按钮时,我正在应用某些浏览器特定的CSS样式.但是下面的html代码不会应用为IE11指定的css(ie11print.css),而是应用为其余IE版本(ieprint.css)指定的css.

<!--[if IE 11]> <link rel="stylesheet" media="print" title="Print" type="text/css" href="/styles/ie11print.css" /><![endif]-->
<!--[if lte IE 10]> <link rel="stylesheet" media="print" title="Print" type="text/css" href="/styles/ieprint.css" /><![endif]-->
<!--[if !IE]>--><link rel="stylesheet" media="print" title="Print" type="text/css" href="/styles/print.css" /><!--<![endif]-->
Run Code Online (Sandbox Code Playgroud)

有人知道如何仅为IE11指定CSS文件吗?提前致谢.

小智 5

使用下面的hack,然后是你的css样式:

*::-ms-backdrop,
Run Code Online (Sandbox Code Playgroud)

例:

*::-ms-backdrop,/*Your element*/ {
       /*Your styles*/
    }
Run Code Online (Sandbox Code Playgroud)

注意:它只会影响IE浏览器.所以你需要在此之前应用你的正常风格.


Dis*_*sha 5

只需在 CSS 样式表中添加以下内容,即可在 Internet Explorer 11 中查看

@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) 
 {                                                                                                                     
             Add your styles here
 }
Run Code Online (Sandbox Code Playgroud)