Last active
December 17, 2015 10:09
-
-
Save derekblank/5592610 to your computer and use it in GitHub Desktop.
Sass @each loop examples
This file contains 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
// Standard loop | |
@each $item in web, design, strategy, development, video, marketing { | |
&#wwd-#{$item} { | |
background-image: url('bg-wwd-#{$item}.jpg'); | |
} | |
} | |
// Multi-dimensional loop | |
a { | |
background: image-url('icons/social-media-sprite.png') no-repeat; | |
display: block; | |
height: 15px; | |
width: 15px; | |
@include hide-text; | |
$network-sprite-map: facebook 5px 0, twitter -26px 0, instagram -57px 0, youtube -87px 0; | |
@each $pair in $network-sprite-map { | |
&.#{nth($pair, 1)}-icon { | |
background-position: #{nth($pair, 2)} #{nth($pair, 3)}; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment