Skip to content

Instantly share code, notes, and snippets.

@panych
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save panych/8844562 to your computer and use it in GitHub Desktop.
Save panych/8844562 to your computer and use it in GitHub Desktop.
Advanced example of sprite generation in Compass
//
// 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