CSS :last-child 伪类
- Trang trước :lang()
- Trang tiếp theo :last-of-type
- Quay lại lớp trên Sách tham khảo pseudo-class CSS
定义和用法
CSS :last-child
伪类用于匹配作为其父元素最后一个子元素的任何元素。
提示:p:last-child
等同于 p:nth-last-child(1)
。
实例
为其父元素的最后一个子元素的 <p> 元素指定背景颜色。同时为其父元素的最后一个子元素的 <li> 元素指定背景颜色:
p:last-child { background-color: yellow; } li:last-child { background-color: yellow; }
CSS 语法
:last-child { css declarations; }
技术细节
版本: | CSS3 |
---|
浏览器支持
Bảng số trong表格指定了完全支持该伪类的首个浏览器版本。
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
4.0 | 9.0 | 3.5 | 3.2 | 9.6 |
Trang liên quan
Tham khảo:Đặc tính ảo :last-of-type trong CSS
- Trang trước :lang()
- Trang tiếp theo :last-of-type
- Quay lại lớp trên Sách tham khảo pseudo-class CSS