针对IE6,IE7,IE8,IE9,firefox的CSS hack经验分享

1区别IE6与其它浏览器:
background:orange; html

_background:blue;

2区别IE6与IE7:
background:green !important; 浏览器

background:blue; spa


3区别IE六、IE7与FF:
background:orange; firefox

*background:green; htm


4区别FF,IE7,IE6:
background:orange; get

*background:green !important; it

*background:blue; io

5区别IE与非IE浏览器
background:orange; import

background:green\9;/*全部IE浏览器都识别(IE六、IE七、IE八、IE9)*/ 方法

注:IE6/7能识别*;标准浏览器(如FF)不能识别*;
background-color:orange\0; /*识别ie 8/9*/
background-color:orange\9\0; /*识别ie 9*/

6 *+html 与 *html 是IE特有的标签, 而*+html 又为 IE7特有标签.

#comments{ width: 120px; } /* FireFox */
*html #comments{ width: 80px;} /* ie6 fixed */
*+html #comments{ width: 60px;} /* ie7 fixed */

注意: *+html 对IE7的HACK 必须保证HTML顶部有以下声明:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

总结 :(注:不论是什么方法,书写的顺序都是firefox的写在前面,IE7的写在中间,IE6的写在最后面) FF不能识别*,但能识别!important; IE7能识别*,也能识别!important; IE6能识别*,但不能识别 !important; IE6支持下划线,IE7和firefox均不支持下划线

相关文章
相关标签/搜索