黄子涵

查漏补缺——说说:nth-of-type(3n)选择器

问题

如题所示

答案

相关源码:

.hzh-friend-item:nth-of-type(3n) {
  margin-right: 0;
}

详解css3中的:nth-of-type(n)

综上所述,:nth-of-type(3n)这个选择器选择的是同类型的第3n个同级兄弟元素。

image

image

你会看到第一行的第三个元素是有右边距的,而第二个元素没有右边距,同理可得。

posted @ 2022-07-09 09:40  黄子涵  阅读(191)  评论(0编辑  收藏  举报