Using nth-child to style item 4 and onwards

前端 未结 2 423
孤独总比滥情好
孤独总比滥情好 2021-02-04 00:23

I have a list item where I\'d like the 4th item and onwards to have a different background-color.

I\'ve tried the following:

li:nth-child(4)         


        
2条回答
  •  别跟我提以往
    2021-02-04 01:21

    Use :nth-child(n+5) (CSS indexes start at 1).

    Demo: http://jsfiddle.net/nTZrg/1/

    li:nth-child(n+5) {
        background-color:blue;
    }
    

提交回复
热议问题