nth-child
nth-of-type
:not()
1.nth-child
1.在子元素上写
:nth-child(n) 选择器匹配属于其父元素的第 N 个子元素,不论元素的类型。
n 可以是数字、关键词或公式。
如:p:nth-child(1/2/3/odd/even/2n/2n+1/3n/)
![](https://img.haomeiwen.com/i12858847/f49538d429a04409.png)
该选择器是找当前元素的父元素下2n个子元素
2.在父元素上写
div+空格 匹配子元素上符合条件的元素
![](https://img.haomeiwen.com/i12858847/160de11cb0b9bc34.png)
2.nth-of-type
1.必须是指定类型的
![](https://img.haomeiwen.com/i12858847/33d93343802cde38.png)
[图片上传中...(image.png-84f95-1541141836218-0)]
3.:not
![](https://img.haomeiwen.com/i12858847/af444e0669a54fc4.png)
![](https://img.haomeiwen.com/i12858847/b684f06091e4a1bd.png)
网友评论