Firefox和IE中css不兼容解决
作者:shenmeng 发布时间:November 11, 2009 分类:
由于IE对标准的支持不好,经常在IE和Firefox中显示不同。
但我们也可以利用IE对标准的不支持来解决这种不兼容:css标准中!important属性提高属性的优先级,但是IE不支持该属性。
所以可以对属性定义两次,用!important 对Firefox定义样式,而IE会忽略有!important的属性,用不带!important对IE定义样式。
例如:
<style>
div#csstest p{
color:red !important;
color:blue;
}
</style>
<div id="csstest">
<p>
Red or Blue ?
</p>
<div id="csstest">
在IE中显示蓝色文本;在Firefox中显示红色文本。