Skip to content

Instantly share code, notes, and snippets.

@pfulton
Forked from robtarr/mixins.scss
Created August 20, 2012 18:33
Show Gist options
  • Save pfulton/3406494 to your computer and use it in GitHub Desktop.
Save pfulton/3406494 to your computer and use it in GitHub Desktop.
Retina SASS mix-in
@mixin hd($defaultPath, $hdPath) {
// the non-hd image - use data URI for this
background-image: inline-image($defaultPath);
// the IE fall-back for non-data URI support
.lt-ie9 & {
background-image: image-url($defaultPath);
}
// the HD version - use regular image path to prevent downloading non-hd version, too
@media (-webkit-min-device-pixel-ratio: 1.5),(-o-min-device-pixel-ratio: 3/2),(min-device-pixel-ratio: 1.5) {
background-image: image-url($hdPath);
background-size: image-width($defaultPath) image-height($defaultPath);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment