样式表突出显示每隔2行

时间:2013-08-26 14:24:38

标签: css3

我一直在读关于css3的n-child,但无法弄清楚我怎么能在 行3,4 | 7,8 | 11,12 | 15,16等是黄色的。 基本上每隔2行都有样式。

由于

1 个答案:

答案 0 :(得分:1)

结合以下内容:

  • 从第3行开始的第4行,即nth-child(4n+3)
  • 从第4行开始每隔4行nth-child(4n+4)) - 它也可以只是nth-child(4n)
table tr:nth-child(4n+3) td, table tr:nth-child(4n+4) td {
    background: red;
}

DEMO