kun*_*mbi 19 css internet-explorer css-selectors css-hack vendor-prefix
由于IE在版本10中摆脱了条件评论,我迫切需要找到一个专门针对IE10的"CSS hack".请注意,它必须是被"黑客"而不是CSS属性的选择器.
在Mozilla中,您可以使用:
@-moz-document url-prefix() {
h1 {
color: red;
}
}
Run Code Online (Sandbox Code Playgroud)
在Webkit中,您通常会这样做:
@media screen and (-webkit-min-device-pixel-ratio:0) {
h1 {
color: blue;
}
}
Run Code Online (Sandbox Code Playgroud)
我如何在IE10中做类似的事情?
小智 33
以下示例显示了如何执行此操作
/*
#ie10 will only be red in MSIE 10,
both in high contrast (display setting) and default mode
*/
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
#ie10 { color: red; }
}
Run Code Online (Sandbox Code Playgroud)
警告:也可能在IE11 +中工作.
小智 5
使用http://rafael.adm.br/css_browser_selector/中的css浏览器选择器,您可以在代码中添加一个简单的+并从CSS中调出IE10.
寻找/msie\s(\d)/并改变它/msie\s(\d+)/.
现在在你的CSS中只需.ie10在你的选择器之前添加如下:
.ie10 .class-name { width: 100px; }
.class-name { width: 90px; }
您现在应该看到IE10呈现100px宽度,所有其他浏览器呈现90px宽度.