本文共 1002 字,大约阅读时间需要 3 分钟。
css选择器除了第一个
This pseudo-class matches an element only if it’s the first child element of its parent element. For instance, li:first-child matches the first list item in an ol or ul element. It doesn’t match the first child of a list item.
仅当该伪类是其父元素的第一个子元素时,它才与该元素匹配。 例如,li:first-child匹配ol或ul元素中的第一个列表项。 它与列表项的第一个子项不匹配。
For example, let’s take the CSS selector mentioned above:
例如,让我们使用上面提到CSS选择器:
li:first-child { ⋮ declarations}
And let’s apply it to the following markup:
并将其应用于以下标记:
Only the first list item element is matched.
仅第一个列表项元素被匹配。
Note that this pseudo-class only applies to elements—it doesn’t apply to anonymous boxes generated for text.
请注意,此伪类仅适用于元素,不适用于为文本生成的匿名框。
This example selector matches the first list item in an ol
or ul
element:
此示例选择器匹配ol
或ul
元素中的第一个列表项:
li:first-child { ⋮ declarations}
翻译自:
css选择器除了第一个
转载地址:http://obrgb.baihongyu.com/