Skip to content

Instantly share code, notes, and snippets.

@besimhu
Last active August 29, 2015 14:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save besimhu/ec91f6c5a8ddd0e3b384 to your computer and use it in GitHub Desktop.
Save besimhu/ec91f6c5a8ddd0e3b384 to your computer and use it in GitHub Desktop.
A simple @each function to loop through a Sass map and generate styles. This is especially handy for when you have and element that reiterates with different settings.
$brand_colors: (
purple $color-purple,
maroon $color-maroon,
orange $color-orange,
yellow $color-yellow,
);
.brand-color-bg {
@each $color in $brand_colors {
&.#{nth($color, 1)} {
$brand_color: nth($color, 2);
background: rgba($brand_color, 0.8);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment