CSS Selector for nth range?

前端 未结 3 689
误落风尘
误落风尘 2020-12-01 01:15

How can I adapt the CSS selector below:

.myTableRow td:nth-child(?){
  background-color: #FFFFCC;
}

so it applies to td columns

3条回答
  •  醉酒成梦
    2020-12-01 01:57

    If you want to select elements 2 through 4, here's how you can do it:

    td:nth-child(-n+4):nth-child(n+2) {
      background: #FFFFCC;
    }
    

    Remind that the selector chain sequence should be from greatest to least. Safari has a bug that prevents this technique from working.

提交回复
热议问题