史上最全的css hack(ie6-9,firefox,chrome,opera,safari)

时间:2022-05-01 09:23:26
 1 <!DOCTYPE html>  
 2 <html>  
 3 <head>  
 4     <title>Css Hack</title>  
 5     <style>  
 6     #test   
 7     {   
 8         width:300px;   
 9         height:300px;   
10          
11 background-color:blue; /*firefox*/ 12 background-color:red\9; /*all ie*/ 13 background-color:yellow\0; /*ie8*/ 14 +background-color:pink; /*ie7*/ 15 _background-color:orange; /*ie6*/
      *display : ie6,ie7
16 } 17 :root #test { background-color:purple\9; } /*ie9*/ 18 @media all and (min-width:0px){ #test {background-color:black\0;} } /*opera*/ 19 @media screen and (-webkit-min-device-pixel-ratio:0){ #test {background-color:gray;} } /*chrome and safari*/ 20 </style> 21 </head> 22 <body> 23 <div id="test">test</div> 24 </body> 25 </html>