CSS 参考手册
CSS3 :last-of-type 选择器
指定其父级的最后一个p元素的背景色
源代码:
点击运行 »
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <style> p:last-of-type { background: #ff0000; } </style> </head> <body> <h1>This is a heading</h1> <p>The first paragraph.</p> <p>The second paragraph.</p> <p>The third paragraph.</p> <p>The fourth paragraph.</p> </body> </html>
运行结果:
点击运行 »