html 选择器之:第几个

  1. 表示选择列表中的第一个标签。p:first-child{}
  2. 表示选择列表中的最后一个标签。p:last-child{}
  3. 表示选择列表中的第3个标签。p:nth-child(3){}
  4. 表示选择列表中的奇数标签。p:nth-child(2n-1){}
  5. 表示选择列表中的偶数标签。p:nth-child(2n){}
  6. 表示选择列表中的标签从第3个开始到最后。p:nth-child(n+3){}
  7. 表示选择列表中的标签从0到3。p:nth-child(-n+3){}
  8. 表示选择列表中的倒数第3个标签。p:nth-last-child(3){}

可以看出,只需要把n看出任何自然数就是我们选择的东西。

猜你喜欢

转载自blog.csdn.net/jk_chen_acmer/article/details/91371782
今日推荐