css选择器除了第一个
描述 (Description)
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:
并将其应用于以下标记:
<ul>
<li>This item matches the selector li:first-child.</li>
<li>This item does not match that selector.</li>
<li>Neither does this one.</li>
</ul>
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.
请注意,此伪类仅适用于元素,不适用于为文本生成的匿名框。
例 (Example)
This example selector matches the first list item in an ol
or ul
element:
此示例选择器匹配ol
或ul
元素中的第一个列表项:
li:first-child {
⋮ declarations
}
css选择器除了第一个