How to select only first three elements using CSS

前端 未结 1 907
萌比男神i
萌比男神i 2021-01-15 18:46

How can I select only first three elements with the :nth-child() selector?

1条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-15 19:34

    You can do it like this:

    section > figure:nth-child(-n+3) {
      border: 1px solid;
    }
    1
    2
    3
    4
    5
    6

    0 讨论(0)
提交回复
热议问题