あなたはこれを行うことができます:
.firstSectionType div{ background: red;} // apply this style to one div.
.firstSectionType span { color: blue; }
.secondSectionType div{ background: blue;} //apply this style to another div.
.secondSectionType span {color: red; }
次に、HTML が次のようになっている場合:
<div class="firstSectionType">
<p><span>Hello</span></p>
<div>This has a red background and <span>this is blue text</span></div>
</div>
<div class="secondSectionType">
<p><span>Hello</span></p>
<div>This has a blue background and <span>this is red text</span></div>
</div>
対応するセクションのdiv
およびspan
は、それに応じてフォーマットされます。
上記の CSS では、各ルールで.firstSectionType
orを繰り返す必要がありますが、 LESS.secondSectionType
のような CSS プリプロセッサを使用すると、次のように書き換えることができます。
.firstSectionType
{
div{ background: red;} // apply this style to one div.
span { color: blue; }
}
.secondSectionType
{
div{ background: blue;} //apply this style to another div.
span {color: red; }
}