Forked from Juice10/compass-retina-sprites.scss
Last active
December 17, 2015 02:18
-
-
Save exocode/5534228 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
@mixin sprite-background($name, $folder) { | |
$sprites: sprite-map("#{$folder}/*.png"); | |
$sprites-retina: sprite-map("#{$folder}@2x/*.png"); | |
background-image: sprite-url($sprites); | |
background-position: sprite-position($sprites, $name); | |
background-repeat: no-repeat; | |
@include inline-block; | |
height: image-height(sprite-file($sprites, $name)); | |
width: image-width(sprite-file($sprites, $name)); | |
@media (-webkit-min-device-pixel-ratio: 2), (-o-min-device-pixel-ratio: 3/2), (min-device-pixel-ratio: 2) { | |
$ypos: round(nth(sprite-position($sprites-retina, $name), 2) / 2); | |
background-position: 0 $ypos; | |
background-size: image-width(sprite-file($sprites, $name)) auto; | |
background-image: sprite-url($sprites-retina); | |
} | |
} | |
// Usage. | |
@import "folder_to_mixin/compass-retina-sprites.scss"; | |
$folder: folder_for_sprites; | |
.mail-icon { | |
@include sprite-background(mail, $folder); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment