css选择器除了第一个_:第一个孩子(CSS选择器)

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:

此示例选择器匹配olul元素中的第一个列表项:

li:first-child {
  ⋮ declarations
}

翻译自: https://www.sitepoint.com/first-child-css-selector/

css选择器除了第一个

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值