案例:CSS3 案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<!DOCTYPE html>
2
<html>
3
<head>
4
<style> 
5
p:nth-child(odd)
6
{
7
background:#ff0000;
8
}
9
p:nth-child(even)
10
{
11
background:#0000ff;
12
}
13
</style>
14
</head>
15
<body>
16
17
<h1>这是标题</h1>
18
<p>第一个段落。</p>
19
<p>第二个段落。</p>
20
<p>第三个段落。</p>
21
<p>第四个段落。</p>
22
23
<p><b>注释:</b>Internet Explorer 不支持 :nth-child() 选择器。</p>
24
25
</body>
26
</html>
27