Skip to content

Instantly share code, notes, and snippets.

@jayaregalinada
Created April 25, 2016 02:16
Show Gist options
  • Save jayaregalinada/a9302c08b1ed0c5a73160536d8390a32 to your computer and use it in GitHub Desktop.
Save jayaregalinada/a9302c08b1ed0c5a73160536d8390a32 to your computer and use it in GitHub Desktop.
Sass Mixin for Margins
@mixin margin($size, $position: false) {
@if $position == false {
margin: $size !important;
}
@else {
margin-#{$position}: $size !important;
}
}
.no-margin {
@include margin(0);
}
@each $position in top, right, bottom, left {
.no-margin-#{$position} {
@include margin(0, $position);
}
.margin-#{$position}-#{auto} {
@include margin(auto, $position);
}
@for $i from 1 through 50 {
@if $i % 10 == 0 {
.margin-#{$position}-#{$i} {
@include margin($i * 1px, $position);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment