我想将主题标签集成到我的元素中,以便它们以不同的颜色显示。但是由于 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; }
该框应该在某处列出,但是一旦它是另一个颜色定义的子子项,它就应该被覆盖。
谢谢你的帮助!