Last active
February 17, 2021 03:56
-
-
Save frankyonnetti/5501945 to your computer and use it in GitHub Desktop.
Scss - retina @2x mixin #scss #retina
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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