“Sel last child”的版本间差异

本页内容
上一节: Sel_nth_last_of_type 下一节: Sel_root
(创建页面,内容为“{{DISPLAYTITLE::last-child}}8 = CSS3 :last-child 选择器 = 完整CSS选择器参考手册 指定父元素中最后一个p元素的背景色: <sample title="" desc="" lang="html" hererun="1"> p:last-child { background:#ff0000; } </sample> <run name=""> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>小白教程(xiaobai.wang)</title> <style> p:last-child { background:#ff0000; } </style…”)
 
Neo讨论 | 贡献
无编辑摘要
 
(未显示同一用户的1个中间版本)
第1行: 第1行:
{{DISPLAYTITLE::last-child}}[[Category:css pseudo classes|8]]
{{DISPLAYTITLE::last-child}}[[Category:css selectors|36]]
= CSS3 :last-child 选择器 =
= CSS3 :last-child 选择器 =


第44行: 第44行:


选择器
选择器
Chrome
Internet Explorer / Edge
Firefox
Safari
Opera


:last-child
:last-child

2022年8月19日 (五) 04:50的最新版本

CSS3 :last-child 选择器

完整CSS选择器参考手册

指定父元素中最后一个p元素的背景色:


示例

p:last-child
{
    background:#ff0000;
}

定义和用法

last-child 选择器用来匹配父元素中最后一个子元素。

提示: p:last-child 等同于 p:nth-last-child(1)。

浏览器支持

表格中的数字表示支持该属性的第一个浏览器版本号。

选择器

Chrome

Internet Explorer / Edge

Firefox

Safari

Opera

last-child

4.0

9.0

3.5

3.2

9.6

更多实例

指定父元素 ul 中最后一个 li 元素,并设置背景颜色:


示例

li:last-child {
  background-color: #ff0000;
}

完整CSS选择器参考手册

上一节: Sel_nth_last_of_type 下一节: Sel_root
此页面最后编辑于2022年8月19日 (星期五) 04:50。