Created
May 1, 2015 13:37
-
-
Save tortillaj/a4b931c5f76ec3b8e04c to your computer and use it in GitHub Desktop.
The @extend directive in Sass
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
<p class="button">Button</p> | |
<p>Somtimes you don't have control over the CSS class. In that case, you can "extend" a previously made class.</p> | |
<p class="something-else">Read More</p> | |
<p>Try overriding a propery in the .something-else class after the @extend directive.</p> |
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.4.13) | |
// Compass (v1.0.3) | |
// ---- | |
$off-black: #4d4d4d; | |
.button { | |
padding: 5px 10px; | |
border: 1px solid $off-black; | |
background-color: white; | |
appearance: none; | |
display: inline-block; | |
transition: background-color 0.25s ease; | |
&:hover { | |
cursor: pointer; | |
background-color: #ccc; | |
} | |
} | |
.something-else { | |
@extend .button; | |
} |
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
.button, .something-else { | |
padding: 5px 10px; | |
border: 1px solid #4d4d4d; | |
background-color: white; | |
appearance: none; | |
display: inline-block; | |
transition: background-color 0.25s ease; | |
} | |
.button:hover, .something-else:hover { | |
cursor: pointer; | |
background-color: #ccc; | |
} |
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
<p class="button">Button</p> | |
<p>Somtimes you don't have control over the CSS class. In that case, you can "extend" a previously made class.</p> | |
<p class="something-else">Read More</p> | |
<p>Try overriding a propery in the .something-else class after the @extend directive.</p> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment