我不知道如何将奇/偶:nth-child()
伪类应用于定义列表
<dl>
<dt>green foo</dt>
<dd>green bar</dd>
<dt>red foo</dt>
<dd>red bar</dd>
<dt>green foo</dt>
<dd>green bar</dd>
</dl>
<style>
dl { color: blue }
dd:nth-child(odd) { color:green }
dd:nth-child(even) { color:red }
</style>
新小提琴:
使用正确的 :nth-of-type 伪类。
dd:nth-of-type(even) {color: red;}
dt:nth-of-type(even) {color: red;}
dd:nth-of-type(odd) {color: green;}
dt:nth-of-type(odd) {color: green;}
</p>