私は 2 つの CSS スタイルを持っています。2 番目のスタイルは、最初のスタイルが存在する場合にのみ有効にしたいと考えています。どうすればそれについて行くでしょうか?クラスタグに複数のクラスを追加できることは知っていますが、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">