: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.