0
我有這樣的HTML代碼第n個孩子()和塊引用CSS
<blockquote>
<cite>oioik wrote:</cite>
<blockquote>
<cite>oioik wrote:</cite>
<blockquote>
<cite>oioik wrote:</cite>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>
</blockquote>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>
</blockquote>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>
</blockquote>
,我有這個CSS
blockquote {
font-size: 13px;
background-color: blue;
border: 0;
padding-left: 50px;
}
blockquote:nth-child(even) {
background-color: red;
}
然後在我的例子中,我應該有藍色/紅色/藍色的背景顏色,但我有藍色/紅色/紅色
這是因爲你的blockquotes是嵌套的 – slash197
甚至是相對於兄弟姐妹的位置 – fcalderan
你喜歡這個http://jsfiddle.net/V59Cq/1/ –