Skip to content

Instantly share code, notes, and snippets.

@felipefunes
Last active December 17, 2015 07:09
Show Gist options
  • Save felipefunes/5570983 to your computer and use it in GitHub Desktop.
Save felipefunes/5570983 to your computer and use it in GitHub Desktop.
Retina Ready Background Mixin with Compass
// 1.- This mixin works when you add class retina by JavaScript to html tag or when you use media queries
// 2.- This solution works with the sprites of http://compass-style.org/
// 3.- If your retina sprite have a diferente size with your regular sprite you can set the image with the folowing mixin:
$icons-retina: sprite-map("icons-retina/*.png");
@mixin background-retina($file-name) {
background: $icons-retina;
$ypos: round(nth(sprite-position($icons-retina, $file-name), 2) / 2);
background-position: 0 $ypos;
@include background-size((image-width(sprite-path($icons-retina))/2) (image-height(sprite-path($icons-retina))/2));
background-repeat: no-repeat;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment