Home  >  Article  >  Web Front-end  >  Summary of css hack including ie6-11, chrome, opera, firefox_html/css_WEB-ITnose

Summary of css hack including ie6-11, chrome, opera, firefox_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:58:22899browse

 1 <!DOCTYPE html>  2 <html>  3 <head>  4 <title>Css Hack ie各版本 opera chrome safari firefox</title>  5 <meta charset=”utf-8″ /> 6 <style>  7 #test  8 {  9 width:300px; 10 height:300px;11 12 background-color:blue; /*firefox*/13 background-color:red\9; /*all ie*/14 background-color:yellow\0; /*ie8*/15 +background-color:pink; /*ie7*/16 _background-color:orange; /*ie6*/17 } 18 :root #test { background-color:purple\9; } /*ie9*/19 @media all and (min-width:0px){ #test {background-color:black\0;} } /*opera*/20 @media screen and (-webkit-min-device-pixel-ratio:0){ #test {background-color:gray;} } /*chrome and safari*/21 @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) { 22     #test { background-color:#00ff00 !important;   }  /* ie10 */23     *::-ms-backdrop, #test {  background-color:#00ffff !important; } /* ie11 */24 }25 </style> 26 </head> 27 <body> 28 <div id='test'>css hack 测试</div> 29 </body> 30 </html>

其中 由于:root 权重较大 所以 ie10 和 ie11 都加了!important。

 

来自 我的博客

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn