Skip to content

Instantly share code, notes, and snippets.

@xyhp915
Forked from frankyonnetti/retina-ready-mixin.scss
Created August 4, 2017 02:26
Show Gist options
  • Save xyhp915/d4cef0e0578e7b11082b4c8b913ab3e2 to your computer and use it in GitHub Desktop.
Save xyhp915/d4cef0e0578e7b11082b4c8b913ab3e2 to your computer and use it in GitHub Desktop.
#sass Retina @2x mixin
// easy retina-ready images
// http://37signals.com/svn/posts/3271-easy-retina-ready-images-using-scss
@mixin image-2x($image, $width, $height) {
@media (-webkit-min-device-pixel-ratio: 2),
(min--moz-device-pixel-ratio: 2),
(-o-min-device-pixel-ratio: 2/1),
(min-device-pixel-ratio: 2),
(min-resolution: 192dpi),
(min-resolution: 2dppx) {
/* on retina, use image that's scaled by 2 */
background-image: url($image);
background-size: $width $height;
}
}
// use full size of 1x image
@include image-2x("../img/[email protected]", WIDTHpx, HEIGHTpx);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment