我无法弄清楚如何将奇/偶:nth-child()
伪类适用于自定义列表:第n个孩子()奇/偶伪类与定义列表
<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>
新小提琴:
用正确的:第n-的方式伪类。
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;}
什么是不工作?你所有的“dd”都是偶数,所以它们都是红色的...... – sczizzo
你想在这些项目之间“有所不同”是什么? – BoltClock
不同的颜色/背景。为什么他们都是?我希望每隔一天dd改变 – helgatheviking