CSS nth-child ignores the first 3 elements, stylize the other 3 and repeats. Possible?

前端 未结 2 1090
执笔经年
执笔经年 2021-01-26 23:27

I know that nth-child is for every nth element, but maybe it\'s possible to ignore the first 3 elements, stylize the other 3 and repeat for a huge list. I tried to write that ev

2条回答
  •  粉色の甜心
    2021-01-27 00:18

    http://jsfiddle.net/bhlaird/7c3aw/ If you want your pattern to repeat every 6 elements (3 on, 3 off) use 6n.

    div:nth-child(6n+4), div:nth-child(6n+5), div:nth-child(6n+6) {
        background-color:#0066cc;
    }
    

提交回复
热议问题