Skip to content

Instantly share code, notes, and snippets.

@TexRx
Forked from starryeyez024/Shorthand-Sass-Extend.css
Created December 15, 2013 21:38
Show Gist options
  • Save TexRx/7978539 to your computer and use it in GitHub Desktop.
Save TexRx/7978539 to your computer and use it in GitHub Desktop.
Shorthand Sass Extend
.foo, .bar {
background: red;
}
// ----
// Sass (v3.3.0.rc.1)
// Compass (v0.13.alpha.10)
// ----
// add this mixin to your Sass file:
@mixin ext($name, $silent: false)
@if $silent == true
@extend %#{$name} !optional
@else
@extend .#{$name} !optional
// then you may extend other classes in a shorter format:
.foo
background: red
%almond
border: pink 1px solid
.bar
+ext(foo)
+ext(almond, true)
//instead of:
//@extend .foo !optional
.joy
+ext(almond, true)
.foo, .bar {
background: red;
}
.bar, .joy {
border: pink 1px solid;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment