Skip to content

Instantly share code, notes, and snippets.

@shkm
Created October 21, 2013 15:24
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 shkm/7085724 to your computer and use it in GitHub Desktop.
Save shkm/7085724 to your computer and use it in GitHub Desktop.
Retina sprites. Given a normal and retina sprite map, along with the name of the sprite, this does magic things. Requires a retina mixin, such as https://gist.github.com/shkm/7085706
// Include normal and retina sprites. Requires retina mixin.
@mixin retina-sprite($map-1x, $map-2x, $sprite, $dimensions: true) {
$position-1x: sprite-position($map-1x, $sprite);
background: sprite-url($map-1x) $position-1x no-repeat;
@if $dimensions {
@include sprite-dimensions($map-1x, $sprite);
}
@include retina {
$map-path-1x: sprite-path($map-1x);
$map-width-1x: image-width($map-path-1x);
$map-height-1x: image-height($map-path-1x);
background-image: sprite-url($map-2x);
background-size: $map-width-1x $map-height-1x;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment