您的位置:首页 > Web前端 > CSS

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

2013-03-05 11:18 169 查看
1区别IE6与其它浏览器:
background:orange;

_background:blue;

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

background:blue;

3区别IE6、IE7与FF:
background:orange;

*background:green;

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

*background:green !important;

*background:blue;

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

background:green\9;/*所有IE浏览器都识别(IE6、IE7、IE8、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均不支持下划线
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: