CSS 参考手册
CSS3 :nth-of-type() Selector
指定每个p元素匹配同类型中的第2个同级兄弟元素的背景色
源代码:
点击运行 »
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <style> p:nth-of-type(2) { 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>
运行结果:
点击运行 »