css选择器 first-child与first-of-type 的区别

时间:2019-07-20 12:00:35   收藏:0   阅读:89

技术分享图片

技术分享图片

 总结:

:first-child 匹配的是某父元素的第一个子元素,就是结构上的第一个子元素。

:first-of-type 匹配的是某父元素该类型的第一个,类型就是冒号前面匹配到的东西,比如 span:first-of-type,就是指父元素里所有span元素中的第一个。

同样类型的选择器 :last-child  和 :last-of-type、:nth-child(n)  和  :nth-of-type(n) 也是这样的。

原文:https://www.cnblogs.com/chm-blogs/p/11216851.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!