css hack基本语法
CSS Hack 分为三类:css类内部hack 、选择器hack 、html头部引用hack
有以下几种写法:
1】
1)ie6 可识别* 不可识别!Important
2)ie7 可识别* 可识别!Important
3)ff 不可识别* 可识别!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]-->