css:伪类:first-child,:nth-child(n),:nth-of-type(n)区别

:first-child,:nth-child(n),:nth-of-type(n)区别

p:first-child
匹配其父元素中的第一个子元素的

元素

p:nth-child(n)
选择所有 p 元素的父元素的第二个子元素(目标元素可以不是p元素)

p:nth-of-type(n)
选择所有p元素第二个为p的子元素

猜你喜欢

转载自blog.csdn.net/m0_49888984/article/details/108148408