Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ambidexterich/8985532 to your computer and use it in GitHub Desktop.
Save ambidexterich/8985532 to your computer and use it in GitHub Desktop.
$sprites: sprite-map("sprites/*.png");
$sprites-retina: sprite-map("sprites-retina/*.png");
@mixin sprite-background($name) {
background-image: sprite-url($sprites);
background-position: sprite-position($sprites, $name);
background-repeat: no-repeat;
@media (-webkit-min-device-pixel-ratio: 2), (-o-min-device-pixel-ratio: 3/2), (min-device-pixel-ratio: 2) {
background-image: sprite-url($icons-retina);
background-position: sprite-position($icons-retina, $name);
@include background-size(image-width(sprite-file($icons, $name)) auto);
}
}
// Usage.
.mail-icon {
@include sprite-background(mail);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment