Skip to content

Instantly share code, notes, and snippets.

@donatj
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save donatj/d4d69335a4fc3801b957 to your computer and use it in GitHub Desktop.
Save donatj/d4d69335a4fc3801b957 to your computer and use it in GitHub Desktop.
SCSS Scaled Sprite Map
@mixin scaled-sprite-background($name, $scale, $spritemap) {
background: $spritemap;
$spritePath: sprite-path($spritemap);
@include background-size(image-width($spritePath) * $scale);
$position: sprite-position($spritemap, $name);
background-position: (nth($position, 1) * $scale) (nth($position, 2) * $scale);
height: image-height(sprite-file($spritemap, $name)) * $scale;
width: image-width(sprite-file($spritemap, $name)) * $scale;
}
@import "ScaledSpriteMap";
@import "compass/utilities/sprites";
$sprites: sprite-map("sprites/*.png");
.example {
@include scaled-sprite-background(spritename, .5, $sprites);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment