我有两个CSS样式,其中第二个样式只想在第一个样式存在时生效。我该如何做?我知道你可以向class标签添加多个类,但似乎不能以相同方式嵌套css标签。
.stat{float: left; width: 200px; height: 40px; padding: 5px; margin: 5px; border: 1px solid #000;}
.stat .red{background-color: #c00;}
<!-- This should have the background color -->
<div class="stat red">
<!-- This should not have the background color -->
<div class="red">
<!-- This should not have the background color -->
<div class="stat">
.stat.red
是一个计算机编程中表示样式的代码。这段代码的意思是设置元素的背景色为红色。 - Tim M.