我簡要介紹了CSS3 Selectors spec,但是找不到如何解決這個問題。另外,當你移動CSS聲明時,我並不期望這個結果發生變化,但它確實如此。任何幫助都會很棒。基於樣式表中訂單的CSS特性/優先級?
div.green_colour div.has_colour{
background-color: green;
}
div.red_colour div.has_colour{
background-color: red;
}
<div class="red_colour">
<div class="green_colour">
<div class="has_colour">
I would like this to be green
</div>
</div>
</div>
<div class="green_colour">
<div class="red_colour">
<div class="has_colour">
I would like this to be red
</div>
</div>
</div>
僅供參考,這是CSS3選擇器規範。 CSS3是模塊化的,所以有51個規格 - 見http://www.w3.org/Style/CSS/current-work。像HTML5一樣,這不是一件大事。 –
我認爲[CSS CSS Cascading and Inheritance]規範](http://www.w3.org/TR/css3-cascade/)中介紹了與移動時具有不同效果的樣式有關的問題。 –
輝煌。非常感謝Paul的鏈接。 – AJP