Created
May 7, 2014 06:29
-
-
Save oklai/9897c602bfd57f70ddc6 to your computer and use it in GitHub Desktop.
Retina sprite for Compass
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
@import "compass/utilities/sprites"; // Include compass sprite helpers | |
@import "compass/css3/background-size"; // Include helper to calc background size | |
// background sprite for retina | |
// Use: | |
// $sprites2x: sprite-map("sprites/*.png", $spacing: 2px); | |
// .icon-new { | |
// @include retina-sprite(icon-new, $sprites2x); | |
// } | |
@mixin retina-sprite($name, $sprites2x, $padding: 0) { | |
background-repeat: no-repeat; | |
@if $padding > 0 { | |
padding: $padding; | |
} | |
$pos: sprite-position($sprites2x, $name, -$padding * 2, -$padding * 2); | |
background-image: sprite-url($sprites2x); | |
background-position: nth($pos, 1) nth($pos, 2) / 2; | |
@include background-size(ceil(image-width(sprite-path($sprites2x)) / 2) auto); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment