已经没什么用了
这是专门针对Chrome和Safari的CSS hack
1 2 3 4 5 6 7 8
| body:nth-of-type(1) .CH{ color: #FF0000; } div { width:100px; height:100px; background:#000; }
|
IE
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| 1. IE6 _div {background:#f99;} 2. IE6 7 *div {background: #f9f;} 3. IE8 9 10 11 div {background:#99f\0;} 4. IE9 10 11 :root div { background:#00f\0; } 5. IE10 11 @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) { div {background:#9ff!important;} } 6. IE11 @media all and (-ms-high-contrast:none) { *::-ms-backdrop,div { background:#9F9!important;} }
|
IE10 hack
第一种
1 2 3 4
| .ie10 .example { background: red; }
|
1 2 3 4 5 6 7 8
| if(false){ document.documentElement.className+=' ie10'; }
if(false){ document.documentElement.className+=' ie' + document.documentMode; }
|
第二种
IE10支持媒体查询,然后也支持-ms-high-contrast这个属性,所以,我们可以用它来Hack IE10
1 2 3
| @media screen and (-ms-high-contrast:active),(-ms-high-contrast: none){ }
|
1 2 3
| if(window.matchMedia("screen and (-ms-high-contrast: active), (-ms-high-contrast: none)").matches){ document.documentElement.className +="ie10"; }
|
第三种
1 2 3 4
| @media screen and (min-width:0\0){ }
|
//