div+css使用!important标记区别Firefox和IE6
[使用!important标记可以区别Firefox和IE6]
Firefox支持!important标记,而IE6忽略!important标记,因此可以使用!important标记区别Firefox和IE6。<html>
<body>
<div style="color: black !important; color: white;">
firefox中显示为黑色文字,IE6中显示为白色文字
</div>
<div style="color: white !important; color: black;">
firefox中显示为白色文字,IE6中显示为黑色文字
</div>
</body>
</html>
[使用!important区分Firefox和IE6时需要放在前面]
<html>
<body>
<div style="color: red !important; color: blue;">
使用!important区别firefox与IE6时,要注意实现原理,Firefox识别!important标记,相当于提升了带有! important的权重,当样式设置为color: red !important; color: blue;时,Firefox认为color: red !important;的权重大于color: blue;,所以Firefox识别为color: red;。而IE6不识别!important标记,当样式设置为color: red !important; color: blue;时,IE6认为color: red !important;的权重和color: blue;的权重相同,由于color: blue;的位置靠后,所以IE6识别为color: blue;。
</div>
<div style="color: red; color: blue !important;">
如果!important设置在靠后。当样式设置为color: red; color: blue !important;时,Firefox认为color: blue !important的权重大于color: red;,所以Firefox识别为color: blue;。而IE6不认别!important标记,当样式设置为color: red; color: blue !important;时,IE6认为color: red;的权重和color: blue !important;的权重相同,由于color: blue !important;的位置靠后,所以IE6也识别为color: blue;。此时,!important就没有起到区分Firefox与IE6的作用。
</div>
</body>
</html>
[div+css关键词]
div css[div+css重要工具]
[div+css的常见问题]
较验div+css格式, http://validator.w3.org/div+css的margin缩写方式
div+css的padding缩写方式
链接的:link,:visited,:hover,:active四种状态
[div+css的浏览器兼容问题]
水平居中,Firefox使用margin-left: auto; margin-right: auto; IE6 使用text-align: center;垂直居中,Firefox中使用display: table-cell; vertical-align: middle;可以实现div垂直居中,而IE6中则需要借助IE6中css的特点实现垂直居中。
!important标记,Firefox支持!important标记,IE6忽略!important标记,!important需要放在前面才能起作用
手形鼠标指针,使用cursor: pointer;