1、 从CSS代码放置的位置看权重优先级:
内联样式 > 内部嵌入样式 > 外联样式
2、 从样式选择器的权重优先级:
Important > 内联样式 > ID > 类、伪类、属性选择器 > 标签、伪元素 > 通配符
今儿,我们重点来看看第2点—样式选择器。
请看以下代码:
DOCTYPE html > head > title > css title > meta http-equiv ="Content-Type" content ="text/html; charset=utf-8" /> style > div.class1 { background : pink ; } .class2 { background : green ; } style > head > body > div class ="class1 class2" style ="width:100px;height:100px;" > div > body > html >
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did115837