div+css使用!important标记区别Firefox和IE6

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重要工具]

Internet Explorer Developer Toolbar, http://www.microsoft.com/downloads/details.aspx?FamilyID=e59c3964-672d-4511-bb3e-2d5e1db91038&amp;displaylang=en

[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;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值