我無法弄清楚如何將奇/偶: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