IE与现代浏览器下CSS的!important属性使用
基本概念:
? 在同一条样式定义中即大括号{ … }中(即同一个选择符的选择器内):
firefox、opera(现代浏览器)优先认领
而ie会忽略!important字符串。
? 在非同一条样式中即不同的大括号{ … }中标有!important的样式对所有浏览器均优先认领。
例一,在同一个选择符的选择器内:
.class{/* 定义字体颜色为红色,并设置!important属性 */color:red !important;/* 定义字体颜色为绿色 */color:green;}.class1{/* 定义字体颜色为红色,并设置!important属性 */color:red !important;}.class2{ /* 定义字体颜色为绿色 */color:green;}#nav a{ color:red;}a{ /*因为包含了!important(对于IE浏览器同样有效)该选择器的color属性将覆盖#nav a的color属性*/color:teal !important;}