二维码防伪系统

新闻中心

各种活动实时推动

nth-child的使用方法是什么?

发布时间:2024-10-24 点击次数:236
1、选择第n个, n代表数字
:.nth-child(n){ }

2、偶数标签

:.nth-child(2n)}
:.nth-child(even){ }

3.奇数标签.

:.nth-child(2n- 1){}
:nth-child(odd){ }

4、负防向范围]选择第1个到第5个

:.nth-child(-n + 5){ }

5、[正方向范围] 选择从第5个开始的,到最后

:nth-child(n + 5){ }

6、[限制范围] 选择第2个到第8个,取两者的交集

:nth-child(-n+8).nth-child(n+2){}

7.倒数第n个标签( n为数字)

:.nth-last-child(n){ }

8、选择第- -个( first-child表示选择列表中的第一个标签)

:first-child{ }

9.选择最后-个( last-child表示选择列表中的最后一个标签)

:last-child{ }

copy © 2025 星澜网络 All Rights Reserved

备案号:鲁ICP备2023015769号