Css伪类选择器

知道first-child、last-child、nth-child(n)、nth-child(2n+1)、nth-child(2n-1)、first-of-type、last-of-type、nth-of-type

nth-child 另一个是:nth-of-type都可以选择父元素下面的子元素。

那么nth-child和nth-of-type有什么区别呢?

我们可以知道nth-child选中的是同一层级的第几个元素。而nth-of-type选中的该类型的第几个元素。

例如:

 

 例如:

 

posted @ 2021-06-03 17:19  洛飞  阅读(45)  评论(0编辑  收藏  举报