CSS 参考手册
CSS3 :nth-child() 选择器
更多实例
源代码:
点击运行 »
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <style> p:nth-child(odd) { background: #ff0000; } p:nth-child(even) { background: #0000ff; } </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><b>注意:</b> Internet Explorer 8 and以及更早版本的浏览器 :nth-child()选择器.</p> </body> </html>
运行结果:
点击运行 »