正方向范围

li:nth-child(n+6)

选中从第6个开始的子元素

负方向范围

:nth-child(-n+9)

选中从第1个到第9个子元素。使用 :nth-child(-n+9) ,就相当让你选中第9个和其之前的所有子元素

前后限制范围

:nth-child(n+4):nth-child(-n+8)

选中第4-8个子元素。使用 nth-child(n+4):nth-child(-n+8) 我们可以选中某一范围内子元素,上面的例子里是从第4个到第8个子元素

奇数、偶数位

:nth-child(odd)

:nth-child(even)

隔选择子元素

:nth-child(3n+1),

选择1,4,7,10

范围高级用法

nth-child(n+2):nth-child(odd):nth-child(-n+9)

使用 nth-child(n+2):nth-child(odd):nth-child(-n+9) 我们将会选中的子元素是从第2位到第9位,并且只包含奇数位。

相关文章:

  • 2022-12-23
  • 2022-01-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-19
猜你喜欢
  • 2022-12-23
  • 2021-06-06
  • 2021-11-05
  • 2022-12-23
  • 2021-12-28
  • 2021-06-30
  • 2021-06-22
相关资源
相似解决方案