问个关于css hack的问题

来源:百度知道 编辑:UC知道 时间:2024/05/28 18:45:05
如果我ie7和FF都显示正常,只是ie6无法兼容的话
我只要加一条ie6能识别的hack。还是说要三种浏览器都写出来?
比如说
div{background:green}对ie6显示不正常的话
应该怎么写?

如果只是IE6不显示,代码如下:
div{background:green!important; background:green;}
因为ie7对important也识别,所以只定义它就行,后面便是ie6的代码

也可以三者都写,代码如下:
div{background:green; *background:green; -background:green}

*background:green是针对ie7,-background:green是针对ie6

还有一个略简单的方法,如果你只想让IE6显示红色背景,那么:

div{background:green;_backgroundL:red;}

_backgroundL:red; 这个就是只针对IE6的,hack的方式是下划线,仅有IE6认识。

background:green!important;/*ff*/

*background:green!important; /*ie7*/

_background:green; /*ie6*/