css selectors nth-child - to target first (n) children

前端 未结 1 1664
情书的邮戳
情书的邮戳 2020-12-15 12:55

I have been trying to target only the first four list items in the using css selector nth-child and/or nth-last-child

  • Hello first
相关标签:
1条回答
  • 2020-12-15 13:46

    Your code works if you fix the typo:

    jsFiddle example

    Although a better solution may be:

     ul li:nth-child(-n+4) {
         font-weight:bold;
     }
    

    jsFiddle example

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