Last active
August 29, 2015 14:23
-
-
Save annez/cfc227928eba4e51f0f3 to your computer and use it in GitHub Desktop.
HIDPI compass image mixin
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
/// Returns a normal or 2x image depending on the DPI of the screen. | |
/// | |
/// @author David Annez | |
/// | |
/// @param {String} $image-path | |
/// The path to the image | |
/// | |
/// @param {String} $format [".png"] | |
/// The format of the file | |
@mixin hidpi-image($image-path, $format: ".png") { | |
$width: #{image-width(#{$image-path}#{$format})}; | |
$height: #{image-height(#{$image-path}#{$format})}; | |
background-size: unquote("#{$width} #{$height}"); | |
background-image: image-url("#{$image-path}#{$format}"); | |
@media screen and (-webkit-min-device-pixel-ratio: 1.5), screen and (min--moz-device-pixel-ratio: 1.5), screen and (-o-device-pixel-ratio: 3 / 2), screen and (min-device-pixel-ratio: 1.5) { | |
background-image: image-url("#{$image-path}-2x#{$format}"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment