How to select all children except first and last with CSS selectors

前端 未结 5 1537
花落未央
花落未央 2020-12-24 10:30

How would I select all the children in a table except for the first and last? I\'ve tried this, but it ends up selecting all children that aren\'t first and all children tha

5条回答
  •  一向
    一向 (楼主)
    2020-12-24 11:23

    like this.

    li:nth-child(n+2):nth-last-child(n+2) { background: red; }
    

    for your requirement

    table.programs tr td:nth-child(n+2):nth-last-child(n+2) { /* Your Style */ }
    

提交回复
热议问题