Created
August 12, 2013 18:42
-
-
Save SimplGy/6213749 to your computer and use it in GitHub Desktop.
Creates 1x and 2x background images. The 200% means that the pixel offsets will work on both the small and large images. Make sure your sprites line up exactly, so that the 2x images are exactly twice as big, twice as low, and twice as left.
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
//Support 1 and 2x image sizes | |
@mixin 2xBackground($url) | |
background-image: url($url + ".png") | |
@media only screen and (-webkit-min-device-pixel-ratio: 1.3), only screen and (min-device-pixel-ratio: 1.3) | |
background-image: url($url + "@2x.png") | |
background-size: 200% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This only works if the bg image happens to be twice as large as the containing element, as is usually the case with sprite sheets that have a normal and hover state. The % is relative to the container, not the image size. Makes this less reusable/flexible than I thought.