权重问题:多个选择器选中一个html元素,css 属性重复的时候,用哪个选择器中的值——>权重高的
权重:
*:0
taget:1
.class:10
#id:100
行内样式:1000
!importent 正无穷 只能是值的覆盖
css样式
html body .red{
color: black;
}
/* 101 */
body #one{
color: blueviolet;
}
/* 100 */
#one{
color: gold;
}
/* 10 */
.red{
color: red;
}
/* 3 */
html>body>p{
color: blue;
}
/* 1 */
p{
color: forestgreen;
}
html
<p class="red" id="one">内容</p>
<p>内容</p>
<p>内容</p>
<p>内容</p>
<p>内容</p>