p:nth-child(2) 要求该元素是p元素,且是父元素的第二个子元素
p:nth-of-type(2) 要求该元素是父元素下的第二个p元素
类似的还有,
:nth-last-child、:nth-last-of-type
:last-child、:last-of-type
本文详细介绍了CSS中的一些关键伪类,如:nth-child、:nth-of-type等的选择器使用方法及其应用场景,帮助读者更好地掌握这些选择器,提升网页布局的灵活性。
p:nth-child(2) 要求该元素是p元素,且是父元素的第二个子元素
p:nth-of-type(2) 要求该元素是父元素下的第二个p元素
类似的还有,
:nth-last-child、:nth-last-of-type
:last-child、:last-of-type
5049
163
1828

被折叠的 条评论
为什么被折叠?
