Created
June 17, 2014 07:46
-
-
Save Lochlan/c55dcbbe7bed4ec02523 to your computer and use it in GitHub Desktop.
Sass: @extend and child selectors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="parent"> | |
parent | |
<div class="child">child</div> | |
<div class="child-foo">child-foo</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ---- | |
// 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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.child, .child-foo { | |
font-size: 2em; | |
color: red; | |
} | |
.child-foo { | |
color: blue; | |
} | |
.parent > .child, .parent > .child-foo { | |
text-decoration: underline; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="parent"> | |
parent | |
<div class="child">child</div> | |
<div class="child-foo">child-foo</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
.parent > .child
rule gets a.parent > .child-foo
selector because of how@extend
works.