0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Extendを使う

Posted at

##Extendって何に使うやつ?

  • セレクタのプロパティを他のセレクタにコピーができる。
  • Extendは参照先がCSSのセレクタになっており、参照元のセレクタのプロパティを書き換えた時に連動して書き換わってしまうので慎重に扱う。

##SCSSでかく

//extend参照元
.hoge {
  width: 10px;
  height: 10px;
  .add {
    display: inline-block;
  }
}

//extendを使う対象
.target {
  @extend .hoge;
  display: block;
}

##CSSにすると…

.hoge, .target {
  width: 10px;
  height: 10px;
}

.hoge .add, .target .add {
  display: inline-block;
}

.target {
  display: block;
}

##使い道について

Mixinでだいたい片付けてしまうので、
「この場合はMixinよりExtendの方が使いやすいよ!」
てのがあればコメントしていただけると助かります…!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?