Is it possible to select every other group of three in CSS?

前端 未结 2 1001
隐瞒了意图╮
隐瞒了意图╮ 2020-12-19 06:31

Is it possible to select every other group of three in CSS? And if it is; how?

So in the sample below apply style to the 4-6 and 10-12 lis.



        
2条回答
  •  甜味超标
    2020-12-19 06:46

    You're looking for nth-child:

    ul li:nth-child(6n+4),ul li:nth-child(6n+5),ul li:nth-child(6n+6) {
        background:red;
    }
    

    http://jsfiddle.net/bhlaird/utEP4/1/

提交回复
热议问题