LoginSignup
6
5

More than 5 years have passed since last update.

SCSSの`&`を使った時の挙動

Last updated at Posted at 2017-12-26

sassで入れ子の中で&を使うと親要素のクラス名を継承できるのですが、
多用するうちにコンパイル後の結果がよくわからなくなるのでメモします。

▼SCSS

.list {
 .item { }

 &::after { }
 
 &__item { }

 & &__item { }
}

▼CSS

.list .item {}

.list::after {}

.list__item {} ※入れ子にならないので注意

.list .list__item {} 

6
5
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
6
5