Skip to content

Instantly share code, notes, and snippets.

@foo9
Last active December 14, 2015 18:49
Show Gist options
  • Save foo9/5132094 to your computer and use it in GitHub Desktop.
Save foo9/5132094 to your computer and use it in GitHub Desktop.
@import "compass/css3/background-size";
$map: sprite-map("sprites/*.png", $layout:smart);
$map-img: sprite-url($map);
@mixin sprite-background($name) {
display: inline-block;
width: image-width(sprite-file($map, $name)) / 2;
height: image-height(sprite-file($map, $name)) / 2;
background-image: $map-img;
background-repeat: no-repeat;
$pos: sprite-position($map, $name);
background-position: ceil(nth($pos, 1) / 2) ceil(nth($pos, 2) / 2);
@include background-size(ceil(image-width(sprite-path($map)) / 2) auto);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment