css的优先级排序?

css的优先级

常用的选择器排序

!important>行内样式>#id>.class>标签(div,p…)

1.!important !权重值无穷大,但也可以计算. 例如
div{
 color:red !important;
}
body div{
 color:red !important;  
 /* 该权重值就大于上方*/
 /* !important使用后不利于后期的调试,尽量用子代,后代叠加权重值 */
 
2.行内样式: 行内样式的权重值为1000

3.#id id的权重值为 :100

4.class的权重值为 10

5.元素选择器权重值为 1

你可能感兴趣的:(前端,javascript,html)