Skip to content

Instantly share code, notes, and snippets.

@swalkinshaw
Forked from replete/_mixin_2ximages.scss
Created January 8, 2013 16:06
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 swalkinshaw/4484977 to your computer and use it in GitHub Desktop.
Save swalkinshaw/4484977 to your computer and use it in GitHub Desktop.
SASS mixin for retina background images. Requires Compass for the image-width and image-height functions.
@mixin image-2x($image1, $image2) {
background-image: url($image1);
@media (min--moz-device-pixel-ratio: 1.3),
(-o-min-device-pixel-ratio: 2.6/2),
(-webkit-min-device-pixel-ratio: 1.3),
(min-device-pixel-ratio: 1.3),
(min-resolution: 1.3dppx) {
background-image: url($image2);
background-size: image-width($image1) image-height($image1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment