-
-
Save duncanmcdougall/5040523 to your computer and use it in GitHub Desktop.
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
#element{ | |
background-image: url('/images/sprite.png'); | |
background-repeat: no-repeat; | |
background-position: -3px 0; | |
} | |
@media (min--moz-device-pixel-ratio: 1.25), | |
(-webkit-min-device-pixel-ratio: 1.25), | |
(min-device-pixel-ratio: 1.25), | |
(min-resolution: 1.25dppx) { | |
#element{ | |
background-size: 100px auto; | |
background-image: url('/images/[email protected]'); | |
background-position: -20px 0; | |
} | |
} |
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
.retina-image(@file, @type, @size: cover, @repeat: no-repeat, @posx: 0, @posy: 0) { | |
background-image: url('@{file}.@{type}'); | |
background-repeat: @repeat; | |
background-position: @posx @posy; | |
@media (min--moz-device-pixel-ratio: 1.25), | |
(-webkit-min-device-pixel-ratio: 1.25), | |
(min-device-pixel-ratio: 1.25), | |
(min-resolution: 1.25dppx) { | |
background-size: @size; | |
background-image: url('@{file}@2x.@{type}'); | |
background-position: @posx * 2 @posy * 2; | |
} | |
} | |
//Example | |
#element{ | |
.retina-image('/images/sprite','png', 100px auto); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Simplified use of original a bit. I mostly use retina images for logos and icons all positioned 0, 0 so by using defaults the syntax is easier to remember. You can get away with as little as .retina-image("myimage", "png");