:last-child

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

 

语法

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

例子

HTML

<p>The first paragraph.</p>
<p>The second paragraph.</p>
<p>The third paragraph.</p>
<p>The fourth paragraph.</p>

CSS

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

执行结果

The first paragraph.

The second paragraph.

The third paragraph.

The fourth paragraph.

参考

相关页面

外部链接