美文网首页
css nth-child等选择器

css nth-child等选择器

作者: zzyo96 | 来源:发表于2018-11-02 15:01 被阅读0次

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/)


image.png

该选择器是找当前元素的父元素下2n个子元素

2.在父元素上写

div+空格 匹配子元素上符合条件的元素


image.png

2.nth-of-type

1.必须是指定类型的
image.png

[图片上传中...(image.png-84f95-1541141836218-0)]

3.:not

image.png image.png

相关文章

网友评论

      本文标题:css nth-child等选择器

      本文链接:https://www.haomeiwen.com/subject/muotxqtx.html