概述
:last-child
CSS 伪类 代表父元素的最后一个子元素。
语法
:last-child
示例
HTML 内容
<ul>
<li>此元素背景色不是lime</li>
<li>我的也不是lime。</li>
<li>我的才是lime! :)</li>
</ul>
CSS 内容
li:last-child {
background-color: lime;
}
规范
Specification | Status | Comment |
---|---|---|
Selectors Level 4 :last-child |
Working Draft | No change |
Selectors Level 3 :last-child |
Recommendation | Initial definition |
浏览器支持
BCD tables only load in the browser
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.