Created
January 24, 2012 17:33
-
-
Save cemre/1671372 to your computer and use it in GitHub Desktop.
Butfirst / Butlast in SCSS
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
/* | |
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