Created
November 6, 2014 16:41
-
-
Save tilap/b6a5c62e9e7358d5b5a5 to your computer and use it in GitHub Desktop.
Retina image url mixin for Less
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
@highdpi: ~"(-webkit-min-device-pixel-ratio: 1.5), (min--moz-device-pixel-ratio: 1.5), (-o-min-device-pixel-ratio: 3/2), (min-resolution: 1.5dppx)"; | |
.retina-bg(@path) { | |
background-image: url(@path); | |
@at2x_path: ~`@{path}.replace(/\.\w+$/, function(match) { return "@2x" + match; })`; | |
@media @highdpi { | |
background-image: url("@{at2x_path}"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment