Forked from pistachiomatt/sprite-generation-with-retina.scss
Created
May 7, 2013 06:52
-
-
Save dbani-dev/5530710 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
// Stick all your icons in a subfolder in your images folder. Mark retina versions with the same filename and "@2x". | |
$sprites: sprite-map("NAME_OF_SUBFOLDER/*.png"); | |
// stolen from 37signals | |
@mixin retina-media() { | |
@media (min--moz-device-pixel-ratio: 1.3), | |
(-webkit-min-device-pixel-ratio: 1.3), | |
(min-device-pixel-ratio: 1.3), | |
(min-resolution: 1.3dppx) { | |
@content; | |
} | |
} | |
@mixin sprite($name) { | |
background-repeat: no-repeat; | |
background-image: sprite-url($sprites); | |
background-position: sprite-position($sprites, $name); | |
height: image-height(sprite-file($sprites, $name)); | |
width: image-width(sprite-file($sprites, $name)); | |
@include retina-media() { | |
background-image: sprite-url($sprites); | |
background-position: sprite-position($sprites, $name+'@2x'); | |
@include background-size( ceil(image-width(sprite-path($sprites)) / 2) ceil(image-height(sprite-path($sprites)) / 2) ); | |
}; | |
} | |
// then when making your icon: | |
button:before { | |
@include sprite( FILENAME_OF_ICON_WITHOUT_EXTENSION ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment