Last active
August 29, 2015 13:56
-
-
Save panych/8844562 to your computer and use it in GitHub Desktop.
Advanced example of sprite generation in Compass
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
// | |
// Usage example: | |
// Image folder: | |
// ic-soc/ | |
// fb.png | |
// tw.png | |
// vk.png | |
// | |
// HTML: | |
// <i class="ic-soc ic-soc_fb"></i> | |
// Use horizontal layout instead smart because problem with no spacing between | |
// sprite parts. | |
$map: sprite-map( | |
'ic-soc/*.png', | |
$layout: horizontal, | |
$spacing: 5px | |
); | |
$names: sprite-names($map); | |
.ic-soc { | |
display: inline-block; | |
vertical-align: middle; | |
background-image: $map; | |
} | |
@each $ic-name in $names { | |
.ic-soc_#{$ic-name} { | |
background-position: sprite-position($map, $ic-name); | |
@include sprite-dimensions($map, $ic-name); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment