FireFox,IE6,IE7浏览器兼容csshack常用解决方法
作者:元如枫 发布于:2010-12-23 17:45 Thursday 分类:学
方法一:加*加!important方法
示例:
.cssName{ width:213px ; *width:213px !important;*width:211px; }
说明:
第一个为firefox下面的,第二个是IE7的,第三个是IE6的
因为:firefox不认 “*”这个东西,也就是后面两个在firefox下面是没有的
因为IE下面“*”是有效的,而且IE7支持“!important”,所以第二个在IE7下面是优先的。自然,第三个就是IE6的
所以使用顺序就是:FireFox,IE7(加*加!important),IE6(加*)
方法二:加*加_方法
示例:
.cssName{
height:20px; /*For Firefox*/
*height:25px; /*For IE7 & IE6*/
_height:20px; /*For IE6*/
}
方法三:样式名称前加*+html方法
示例:
#cssName { color: #333; } /* Moz */
* html #cssName { color: #666; } /* IE6 */
*+html #cssName { color: #999; } /* IE7 */
方法四:IE专用条件注释方法
示例:
<!-- 其他浏览器 -->
<link rel="stylesheet" type="text/css" href="css.css" />
<!--[if IE 7]>
<!-- 适合于IE7 -->
<link rel="stylesheet" type="text/css" href="ie7.css" />
< ![endif]-->
<!--[if lte IE 6]>
<!-- 适合于IE6及一下 -->
<link rel="stylesheet" type="text/css" href="ie.css" />
< ![endif]-->

