CSS selector for other than the first child and last child

前端 未结 2 1673
我寻月下人不归
我寻月下人不归 2021-01-30 09:50

I am making a very advanced website. My question: Is it possible to select all the other children except for the :first-child and the :last-child? I kn

相关标签:
2条回答
  • 2021-01-30 10:43

    Try:

    #navigation ul li:not(:first-child):not(:last-child) {
      ...
    }
    
    0 讨论(0)
  • 2021-01-30 10:43

    Sure it will work, you just have to use two 'not' selectors.

    #navigation ul li:not(:first-child):not(:last-child) {
    

    It will continue down the line after the first one, saying "not the first child" and "not the last child".

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