css hack基本语法

CSS Hack 分为三类:css类内部hack  、选择器hack  html头部引用hack

有以下几种写法:

1

1ie6  可识别不可识别Important

2ie7  识别*   识别Important

3ff   不可识别识别Important

区分ff   ie7  ie6(按顺序)

.test{

background-color:red;

*background-color:red !important;

*background-color:red;

}

.test{

background-color:red;

*background-color:red ;

_background-color:red;

}

2】(class=“test”)

ie6     *html.test{}    

ie 7     *+html.test{}

*+html必须保证HTML顶部有如下声明: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 

"http://www.w3.org/TR/html4/loose.dtd">  

3

ie6 ie7 ie 8    可识别    \9  

ie8 ie9      可识别      \0

ie9          可识别   \9\0

 :root #test { background-color:purple\9; }  /*仅仅ie9可识别*/

@media all and (min-width:0px){ #test {background-color:black\0;} }  /*opera*/
@media screen and (-webkit-min-device-pixel-ratio:0){#test {background-color:gray;} }  /*chrome and safari*/

4

<!--[if IE 7]> 可以包含style标签,也可以包含普通html代码<![endif]-->

posted @ 2013-07-15 14:50  小女子意  阅读(211)  评论(0编辑  收藏  举报