奇偶数匹配
odd代表奇数,even代表偶数
li:nth-of-type(odd) {
background-color: rgb(238, 238, 238);
}
li:nth-of-type(even) {
background-color: white;
}
倍数写法
:nth-child(2n+1), :nth-child(2n-3) , :nth-child(4n+3),可以这样写。n为自然数
li:nth-of-type(2n-1) {
background-color: rgb(238, 238, 238);
}
li:nth-of-type(2n) {
background-color: white;
}