我似乎不能改變我的div的背景,當他們在裏面。我認爲這個問題是在我的元素都在爲了做到。nth類型不工作列表內
<ul class="featured-items">
<li><div class="inner"><div class="item-content"></div></div></li>
<li><div class="inner"><div class="item-content"></div></div></li>
<li><div class="inner"><div class="item-content"></div></div></li>
</ul>
.featured-items li .inner:nth-of-type(1) {
background-image: url(../images/phone.jpg);
}
.featured-items li .inner:nth-of-type(2) {
background-image: url(../images/firelace.jpg);
}
目前,每一個內顯示"phone.jpg"
。
我想':第n-的-type'應與''一樣.featured項麗li':第n-的式(1).inner {...} ' –
https://developer.mozilla.org/de/docs/Web/CSS/:nth-of-type _「:nth-type(an + b)CSS僞類匹配一個元素,該元素具有+ b-1兄弟姐妹在文檔樹中有相同的元素名稱「_ - 你的'.inner'元素沒有_any_兄弟姐妹,它們都是它們父代的唯一孩子。 – CBroe