Created
January 27, 2015 18:52
-
-
Save markhalliwell/e04d2775854fd24b56fb to your computer and use it in GitHub Desktop.
SASS Helper Classes
This file contains hidden or 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
| // Helper classes. | |
| @each $property in (border, margin, padding) { | |
| @each $direction in ('', -left, -right, -top, -bottom) { | |
| .#{$property}#{$direction} { | |
| @if $property == border { | |
| #{$property}#{$direction}: 1px solid $gray-lighter; | |
| } | |
| @else { | |
| #{$property}#{$direction}: 1em; | |
| } | |
| @if $direction == -top { | |
| &:not(.no-first):first-of-type { | |
| #{$property}#{$direction}: 0; | |
| } | |
| } | |
| @else if $direction == -bottom { | |
| &:not(.no-last):last-of-type { | |
| #{$property}#{$direction}: 0; | |
| } | |
| } | |
| } | |
| .no-#{$property}#{$direction} { | |
| #{$property}#{$direction}: 0; | |
| &.important { | |
| #{$property}#{$direction}: 0 !important; | |
| } | |
| } | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This creates the following classes, all of which can add a prefix of
no-which would instead set the property to0.Border
borderborder: 1px solid $gray-lighter;border-leftborder-left: 1px solid $gray-lighter;border-rightborder-right: 1px solid $gray-lighter;border-topborder-top: 1px solid $gray-lighter;border-bottomborder-bottom: 1px solid $gray-lighter;Margin
marginmargin: 1em;margin-leftmargin-left: 1em;margin-rightmargin-right: 1em;margin-topmargin-top: 1em;margin-bottommargin-bottom: 1em;Padding
paddingpadding: 1em;padding-leftpadding-left: 1em;padding-rightpadding-right: 1em;padding-toppadding-top: 1em;padding-bottompadding-bottom: 1em;