参见英文答案 >
Detecting IE11 using CSS Capability/Feature Detection15个答案我如何才能入侵或编写CSS只为IE 11?我有一个网站,看起来不错在IE 11.我只是在这里搜索,但没有找到任何解决方案。
有没有任何css选择器?
解决方法
使用Microsoft特定的CSS规则组合过滤IE11:
<!doctype html> <html> <head> <title>IE10/11 Media Query Test</title> <Meta charset="utf-8"> <Meta http-equiv="X-UA-Compatible" content="IE=edge"> <style> @media all and (-ms-high-contrast:none) { .foo { color: green } /* IE10 */ *::-ms-backdrop,.foo { color: red } /* IE11 */ } </style> </head> <body> <div class="foo">Hi There!!!</div> </body> </html>
过滤器如此工作原因如下:
When a user agent cannot parse the selector (i.e.,it is not valid CSS 2.1),it must ignore the selector and the following declaration block (if any) as well.
参考文献
> How do I target only Internet Explorer 10 for certain situations like Internet Explorer-specific CSS or Internet Explorer-specific JavaScript code?
> Microsoft Extensions to CSS
> CSS 2.1:Rule sets,declaration blocks,and selectors