👓
RSCSS 日本語訳
  • Introduction
  • コンポーネント(Components)
    • コンポーネント について
    • エレメント(Elements)
    • バリアント(Variants)
    • ネストされたコンポーネント (Nested Components)
    • レイアウト(Layouts)
    • ヘルパー(Helpers)
  • 構造(Structure)
    • CSS Structure
  • 付記
    • 落とし穴
    • 懸念点
    • リソース
  • 要約
  • 外部リソース
    • 翻訳
Powered by GitBook
On this page

Was this helpful?

  1. 付記

落とし穴

ネストされたコンポーネントでの Bleeding

同じエレメント名を親コンポーネントと共有するネストされたコンポーネントに気をつけてください.

<article class='article-link'>
 <div class='vote-box'>
    <button class='up'></button>
    <button class='down'></button>
    <span class='count'>4</span>
  </div>

  <h3 class='title'>Article title</h3>
  <p class='count'>3 votes</p>
</article>
.article-link {
  > .title { /* ... */ }
  > .count { /* ... (!!!) */ }
}

.vote-box {
  > .up { /* ... */ }
  > .down { /* ... */ }
  > .count { /* ... */ }
}

この場合, もし .article-link > .count で > (子セレクタ)を指定されていない場合、 .vote-box .count 要素にも同様のルール適用されてしまいます. これが子セレクタが望ましい理由の一つです.

PreviousCSS StructureNext懸念点

Last updated 5 years ago

Was this helpful?