1. 除去首个元素

li:not(:first-child)
li + li
li:first-child ~ li

2. 第1-3个元素

li:nth-child(-n+3)

3. 除去第1-3个元素

li:not(:nth-child(-n+3))

4.第5-10个子元素

table tr:nth-child(n+5):nth-child(-n+10) {
  background-color: red;
}

5.倒数第四个以及之前的元素

:nth-last-child(n+4)

6. .list里面li元素个数大于等于4,则显示为红色(数量感知)

.list li:nth-last-child(n+4) ~ li,
.list li:nth-last-child(n+4):first-child {
  color: red
}

 

相关文章:

  • 2021-09-20
  • 2022-02-08
  • 2022-12-23
  • 2022-02-08
  • 2022-12-23
  • 2021-06-16
  • 2022-12-23
猜你喜欢
  • 2021-12-13
  • 2021-11-02
  • 2022-02-02
  • 2022-12-23
  • 2022-03-03
  • 2022-12-23
  • 2022-01-22
相关资源
相似解决方案