Skip to content

Instantly share code, notes, and snippets.

@cancer
Created July 18, 2014 08:23
Show Gist options
  • Save cancer/7473e8c1d64f09054a71 to your computer and use it in GitHub Desktop.
Save cancer/7473e8c1d64f09054a71 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.3.10)
// Compass (v1.0.0.alpha.20)
// ----
/* 0: これだとBlockの子要素になっちゃう */
.list {
%list__item {
background: limegreen;
}
&__item--mod1 { @extend %list__item; color: salmon; }
&__item--mod2 { @extend %list__item; color: chocolate; }
}
/* 1: PlaceholderをBlockの外に書くパターン */
%list-item {
background: tomato;
}
.list {
&__item { @extend %list-item; }
&__item--mod1 { @extend %list-item; color: salmon; }
&__item--mod2 { @extend %list-item; color: chocolate; }
}
/* 2: @at-rootを使ってPlaceholderをBlockの外に出すパターン */
.list {
@at-root {
%list__item {
background: plum;
}
}
&__item--mod1 { @extend %list__item; color: salmon; }
&__item--mod2 { @extend %list__item; color: chocolate; }
}
/* 3: @at-rootを使ってPlaceholderをBlockの外に出した上で、class(Element)と書き方を揃えるパターン */
.list {
@at-root {
%list__item {
background: plum;
}
&__item--mod1 { @extend %list__item; color: salmon; }
&__item--mod2 { @extend %list__item; color: chocolate; }
}
}
@charset "UTF-8";
/* 0: これだとBlockの子要素になっちゃう */
.list .list__item--mod1, .list .list__item--mod2 {
background: limegreen;
}
.list__item--mod1 {
color: salmon;
}
.list__item--mod2 {
color: chocolate;
}
/* 1: PlaceholderをBlockの外に書くパターン */
.list__item, .list__item--mod1, .list__item--mod2 {
background: tomato;
}
.list__item--mod1 {
color: salmon;
}
.list__item--mod2 {
color: chocolate;
}
/* 2: @at-rootを使ってPlaceholderをBlockの外に出すパターン */
.list__item--mod1, .list__item--mod2 {
background: plum;
}
.list__item--mod1 {
color: salmon;
}
.list__item--mod2 {
color: chocolate;
}
/* 3: @at-rootを使ってPlaceholderをBlockの外に出した上で、class(Element)と書き方を揃えるパターン */
.list__item--mod1, .list__item--mod2 {
background: plum;
}
.list__item--mod1 {
color: salmon;
}
.list__item--mod2 {
color: chocolate;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment