Joh*_*ith 10 css css-selectors css3
我想使用CSS3的nth-child选择器在两行厚的背景颜色之间交替,而不是在使用时通常的一行nth-child(odd).
所以我们有一张桌子:
ROW 1: Blue
ROW 2: Blue
ROW 3: Red
ROW 4: Red
ROW 5: Blue
ROW 6: Blue
Run Code Online (Sandbox Code Playgroud)
Mat*_*ias 21
你可以用这个:
tr {
background: blue;
}
tr:nth-child(4n+1), tr:nth-child(4n+2) {
background: red;
}
Run Code Online (Sandbox Code Playgroud)
n 将从0开始计算.