Skip to content

Instantly share code, notes, and snippets.

@Shpigford
Created July 5, 2013 14:50
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 Shpigford/5935076 to your computer and use it in GitHub Desktop.
Save Shpigford/5935076 to your computer and use it in GitHub Desktop.
Single-resource retina sprites
$icons: sprite-map("icons/*.png", $spacing: 3px);
@mixin responsive-sprite($icon) {
$iconname: "icons/#{$icon}.png";
$iconwidth: round(image-width($iconname)/2);
$iconheight: round(image-height($iconname)/2);
$pos: sprite-position($icons, $icon);
$posx: round(nth($pos, 1)/2);
$posy: round(nth($pos, 2)/2);
width: $iconwidth;
height: $iconheight;
background: sprite-url($icons) $posx $posy no-repeat;
@include background-size(round(image-width(sprite-path($icons)) / 2) round(image-height(sprite-path($icons)) / 2));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment