我想將主題標籤集成到我的元素中,以便它們顯示爲不同的顏色。但由於css選擇器具有相同的css特性,因此最新版本會覆蓋先前定義的規則。更改兒童的特異性
這是顯示我的問題的例子:
<div class="red">
<div class="box">This should be red</div>
<div class="yellow">
...
<div class="box">This should be yellow (nested in x levels under the div.yellow)</div>
...
</div>
,在這裏我的CSS
.box { width: 100px; height: 100px; }
.yellow { background-color: yellow; }
.red { background-color: red; }
包裝箱內應某上市,但只要它是另一種顏色的子子它應該被覆蓋。
感謝您的任何幫助!
這是動態的嗎?如果不是僅僅使用:class =「box yellow」作爲其類 – Treby 2009-12-15 07:55:05
它是黃色的。我猜這個問題在其他地方。可能涉及。黃色浮動或.box被絕對定位的所有內容。無論問題出在哪裏,它都不適用於你向我們展示的代碼。 – Quentin 2009-12-20 14:02:04