Skip to content

Instantly share code, notes, and snippets.

@cemre
Created January 24, 2012 17:33
Show Gist options
  • Save cemre/1671372 to your computer and use it in GitHub Desktop.
Save cemre/1671372 to your computer and use it in GitHub Desktop.
Butfirst / Butlast in SCSS
/*
Apply a style to all elements but the first or last one.
Such as:
.items {
@include butfirst(margin-top, 10px);
}
.menu-item {
@include butlast(margin-right, 10px);
}
*/
@mixin butfirst($property, $v) {
#{$property}: #{$v};
&:first-child {
#{$property}: 0;
}
}
@mixin butlast($property, $v) {
#{$property}: #{$v};
&:last-child {
#{$property}: 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment