Skip to content

Instantly share code, notes, and snippets.

@mz026
Created December 15, 2014 07:34
Show Gist options
  • Save mz026/58c30ff2699a76b35a0d to your computer and use it in GitHub Desktop.
Save mz026/58c30ff2699a76b35a0d to your computer and use it in GitHub Desktop.
$buttons2x-sprites: sprite-map('buttons2x/*.png');
%buttons2x-sprite {
background-image: sprite-url($buttons2x-sprites);
}
@mixin buttons2x-sprite($sprite-name){
@extend %buttons2x-sprite;
background-repeat: no-repeat;
$xpos: (nth(sprite-position($buttons2x-sprites, $sprite-name), 1) / 2);
$ypos: (nth(sprite-position($buttons2x-sprites, $sprite-name), 2) / 2);
background-position: $xpos $ypos;
height: image-height(sprite-file($buttons2x-sprites, $sprite-name)) / 2;
width: image-width(sprite-file($buttons2x-sprites, $sprite-name)) / 2;
@include background-size(image-width(sprite-path($buttons2x-sprites))/2 image-height(sprite-path($buttons2x-sprites))/2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment