!important详解
!imprtant的作用是提高指定样式规则的应用优先权
ie7,ie8,firefox,chrome等高端浏览器下,已经可以识别 !important属性, 但是IE 6.0仍然不能完全识别
不说理论了,直接贴代码,这段代码,在ie7+,firefox,chrome都显示红色,在ie6显示蓝色,因为ie6不识别该属性。
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>!improtant</title>
<style type="text/css">
div{
color:red !important;
color:blue;
}
</style>
</head>
<body>
<div>!important</div>
</body>
</html>
<html>
<head>
<meta charset="UTF-8">
<title>!improtant</title>
<style type="text/css">
div{
color:red !important;
color:blue;
}
</style>
</head>
<body>
<div>!important</div>
</body>
</html>
运行结果:
ie6:!improtant
ie7+,firefox,chrome:!improtant