Created
December 23, 2015 13:41
-
-
Save dtuite/3d1bbf70bf0027ad4298 to your computer and use it in GitHub Desktop.
SCSS Loop for defining margin helpers.
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
$distances: ("s": 10px, "m": 25px); | |
$sides: left, top, bottom, right; | |
// This nested loop defines a set of spacer classes which we can use to place margins between | |
// elements. | |
// | |
// It generates slelectors which look like this: | |
// | |
// .ml--s { | |
// margin-left: 10px; | |
// } | |
// .mt--m { | |
// margin-left: 25px; | |
// } | |
// | |
// The naming scheme is [m]argin[l]eft--[s]mall, [m]argin[t]op--[m]edium etc. | |
@each $label, $distance in $distances { | |
@each $side in $sides { | |
.m#{str-slice($side, 0, 1)}--#{$label} { | |
margin-#{$side}: $distance; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment