Last active
December 16, 2015 07:19
-
-
Save 2ndkauboy/5397443 to your computer and use it in GitHub Desktop.
A simple mixin to use a different background images for HiDPI devices.
This file contains 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
@mixin background-image-hidpi($normalImage, $hdpiImage, $ratio){ | |
// normal image | |
background-image: url('#{$normalImage}'); | |
// high dpi image | |
@include pixel-ratio($ratio){ | |
background-image: url('#{$hdpiImage}'); | |
} | |
} | |
// This mixin uses the mixin pixel-ratio() which you can find in anoter gist: https://gist.github.com/2ndkauboy/5397402 | |
@mixin pixel-ratio($ratio){ | |
@media (-webkit-min-device-pixel-ratio: $ratio), (min--moz-device-pixel-ratio: $ratio), (min-resolution: #{$ratio}dppx), (min-resolution: #{$ratio * 96}dpi){ | |
@content; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment