<分区>
我想使用 CSS3 的 nth-child
选择器在两行厚的背景颜色之间交替,而不是使用 nth-child(odd)
时通常的一行。
The "Result" section of this jsFiddle illustrates what I want.
所以我们会有一张 table :
ROW 1: Blue
ROW 2: Blue
ROW 3: Red
ROW 4: Red
ROW 5: Blue
ROW 6: Blue
标签 css css-selectors
<分区>
我想使用 CSS3 的 nth-child
选择器在两行厚的背景颜色之间交替,而不是使用 nth-child(odd)
时通常的一行。
The "Result" section of this jsFiddle illustrates what I want.
所以我们会有一张 table :
ROW 1: Blue
ROW 2: Blue
ROW 3: Red
ROW 4: Red
ROW 5: Blue
ROW 6: Blue
最佳答案
你可以使用这个:
tr {
background: blue;
}
tr:nth-child(4n+1), tr:nth-child(4n+2) {
background: red;
}
n
将从 0 开始计数。
关于css - 第 n 个 child 交替 2 行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22994062/