Select the last 3 child elements

后端 未结 3 839
一个人的身影
一个人的身影 2021-02-01 12:15

I know you can select the last child with :last-child or a certain child with :nth-child (if you know their position/number).

What I need is to

3条回答
  •  情话喂你
    2021-02-01 13:10

    This is possible with CSS3 selectors and formulas:

    .something a:nth-last-child(-n+3) { ... }
    

    You could also try using jQuery (example) or adding a specific class to the last three elements in your server-side code (it does not require JavaScript to be enabled in browsers and also works on older browsers that do not support CSS3).

提交回复
热议问题