针对firefox ie6 ie7 ie8的css样式hack

【字号: 日期:2024-05-26浏览:27作者:雯心
针对firefox ie6 ie7 ie8的css样式hack 以前我们大部分都是用!important来hack,对于ie6和firefox测试可以正常显示,但是ie7以上对!important可以正确解释,会导致页面没按要求显示!搜索了一下,找到了一个针对IE7、IE8不错的hack方式,IE7使用*+html或*line-height: 23px,IE8使用9来区分,比如:line-height: 26px9。 CSS可以参照如下定义,注意顺序: #menu { line-height: 23px; }/* firefox 浏览器实行这句定义 */ #menu { line-height: 26px9; }/*ie6,ie7,ie8 这句定义主要尖对IE8来hack*/ #menu { *line-height: 23px; }/*ie6,ie7 这句定义主要尖对IE7来hack*/ #menu { _line-height: 23px; }/*ie6 浏览器优先实行这句定义*/ 或者写成一句 #menu { line-height:23px; line-height: 26px9; *line-height: 23px; _line-height:23px; } 或者 * html #menu { line-height: 23px; } /* IE6 浏览器实行这句定义 */ *+html #menu { line-height: 23px; }/* IE7 浏览器实行这句定义*/
相关文章: