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; | |
} | |
} | |
} | |
} |
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
border
border: 1px solid $gray-lighter;
border-left
border-left: 1px solid $gray-lighter;
border-right
border-right: 1px solid $gray-lighter;
border-top
border-top: 1px solid $gray-lighter;
border-bottom
border-bottom: 1px solid $gray-lighter;
Margin
margin
margin: 1em;
margin-left
margin-left: 1em;
margin-right
margin-right: 1em;
margin-top
margin-top: 1em;
margin-bottom
margin-bottom: 1em;
Padding
padding
padding: 1em;
padding-left
padding-left: 1em;
padding-right
padding-right: 1em;
padding-top
padding-top: 1em;
padding-bottom
padding-bottom: 1em;