id: 百位class: 十位tag: 个位
如:
body h1 {
color: violet;
}
它的id为0,class为0,tag为2。所以它的权重就是 : 0,0,2
!important: 是最高指示,忽略任何权重
h1 {
color: chartreuse !important;
}
:nth-of-type(an+b)
.list> :nth-of-type(-n + 3) {
background-color: lightgreen;
}
/ -10 + 3 = 3-11 + 3 = 3-1 = 2-12 + 3 = 3-2 = 1-1*3+3 = 3-3 = 0
[3,2,1] */
.list> :nth-of-type(odd) {
background-color: lightgreen;
}
.list> :nth-of-type(even) {
background-color: lightgreen;
}
odd为奇数, even为偶数。
相关推荐
© 2020 asciim码
人生就是一场修行