Skip to content

Instantly share code, notes, and snippets.

@Lochlan
Created June 17, 2014 07:46
Show Gist options
  • Save Lochlan/c55dcbbe7bed4ec02523 to your computer and use it in GitHub Desktop.
Save Lochlan/c55dcbbe7bed4ec02523 to your computer and use it in GitHub Desktop.
Sass: @extend and child selectors
<div class="parent">
parent
<div class="child">child</div>
<div class="child-foo">child-foo</div>
</div>
// ----
// Sass (v3.3.8)
// Compass (v1.0.0.alpha.19)
// ----
.child {
font-size: 2em;
color: red;
}
.child-foo {
@extend .child;
color: blue;
}
.parent > .child {
text-decoration: underline;
}
.child, .child-foo {
font-size: 2em;
color: red;
}
.child-foo {
color: blue;
}
.parent > .child, .parent > .child-foo {
text-decoration: underline;
}
<div class="parent">
parent
<div class="child">child</div>
<div class="child-foo">child-foo</div>
</div>
@Lochlan
Copy link
Author

Lochlan commented Jun 17, 2014

The .parent > .child rule gets a .parent > .child-foo selector because of how @extend works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment