CSS 选择器 选择前几个元素
CSS 选择器 选择前几个元素
- 选择第n个,n代表数字
:nth-child(n){ }
- 选择列表中的偶数的标签
:nth-child(2n){ }
- 选择列表中的奇数标签
:nth-child(2n-1){ }
- 【负方向范围】选择第1个到第6个
:nth-child(-n+6){ }
- 【正方向范围】选择从第6个开始的,直到最后
:nth-child(n+6){ }
- 【限制范围】选择第6个到第9个,取两者的交集
:nth-child(-n+9):nth-child(n+6){ }
- 选择列表中的倒数第n个标签 n为数字
:nth-last-child(n){ }
- 需要设置前3个元素
:nth-child(-n+3){ }
- 选择第一个 ( first-child表示选择列表中的第一个标签 )
:first-child{ }
- 选择最后一个 ( last-child表示选择列表中的最后一个标签 )
:last-child{ }
原文章 https://blog.csdn.net/idomyway/article/details/93921248
还没有评论,来说两句吧...