👓
RSCSS 日本語訳
  • Introduction
  • コンポーネント(Components)
    • コンポーネント について
    • エレメント(Elements)
    • バリアント(Variants)
    • ネストされたコンポーネント (Nested Components)
    • レイアウト(Layouts)
    • ヘルパー(Helpers)
  • 構造(Structure)
    • CSS Structure
  • 付記
    • 落とし穴
    • 懸念点
    • リソース
  • 要約
  • 外部リソース
    • 翻訳
Powered by GitBook
On this page
  • 位置指定プロパティを避ける
  • 固定サイズ
  • 親要素で位置指定する

Was this helpful?

  1. コンポーネント(Components)

レイアウト(Layouts)

Previousネストされたコンポーネント (Nested Components)Nextヘルパー(Helpers)

Last updated 5 years ago

Was this helpful?

位置指定プロパティを避ける

コンポーネントは異なるコンテキストで再利用可能なように作られるべきです. なので以下のようなプロパティをコンポーネントで指定することは避けてください.

  • 位置指定(position, top , left , right , bottom)

  • Floats (float , clear )

  • マージン(margin)

  • 寸法(width , height)

固定サイズ

ただしアバターやロゴのような固定サイズの要素は例外として扱うことが出来ます.

親要素で位置指定する

もし位置指定が必要な場合その要素が存在するコンテキストで定義してみてください. 下記の例でコンポーネントそれ自体ではなく、リストコンポーネントにwidthとfloatが適用されているように.

.article-list {
  & {
    @include clearfix;
  }

  > .article-card {
    width: 33.3%;
    float: left;
  }
}

.article-card {
  & { /* ... */ }
  > .image { /* ... */ }
  > .title { /* ... */ }
  > .category { /* ... */ }
}

レイアウトの外のマージンを指定するにはどうしたらいいでしょう?ヘルパーでやってみましょう

Continue →
.recipe-listというレイアウトと.recipe-itemコンポーネント