Skip to content

Instantly share code, notes, and snippets.

@averyvery
Created November 29, 2011 22:09
Show Gist options
  • Save averyvery/1406790 to your computer and use it in GitHub Desktop.
Save averyvery/1406790 to your computer and use it in GitHub Desktop.
Retina and non-retina backgrounds with Sass
@mixin mobile-sprite($selector, $image){
#{$selector} {
background-image: image-url('mobilenormal/' + $image);
}
@media only screen and (-webkit-min-device-pixel-ratio: 2){
#{$selector} {
$image_path: 'mobilenormal/' + $image;
background-image: image-url('mobileretina/' + $image);
background-size: image-width($image_path) image-height($image_path);
}
}
}
@include mobile-sprite('.header', 'header.png');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment