Skip to content

Instantly share code, notes, and snippets.

@vitto
Last active August 29, 2015 14:01
Show Gist options
  • Save vitto/80384a742e0cc6b251e7 to your computer and use it in GitHub Desktop.
Save vitto/80384a742e0cc6b251e7 to your computer and use it in GitHub Desktop.
Frontsize - How to create a multiple size SVG sprites
These are 16px sprites
<div class="sprites-16 foo"></div>
<div class="sprites-16 bar"></div>
These are 32px sprites using the same SVG image
<div class="sprites-32 foo"></div>
<div class="sprites-32 bar"></div>
@spriteWidth: 16px;
@spriteHeight: 16px;
@backgroundWidth: 512px;
@backgroundHeight: 512px;
.sprite-16,
.sprite-32 {
.sprite("sprites-16.svg", @spriteWidth);
}
.sprite-16 {
.setSprite(foo, 0, 0, @spriteWidth, @spriteHeight);
.setSprite(bar, 1, 0, @spriteWidth, @spriteHeight);
}
.sprite-32 {
@scale: 2;
.scaleSprite(@scale, @spriteWidth, @spriteHeight, @backgroundWidth, @backgroundHeight);
.setSprite(foo, 0, 0, @spriteWidth, @spriteHeight, @scale);
.setSprite(bar, 1, 0, @spriteWidth, @spriteHeight, @scale);
}
@vitto
Copy link
Author

vitto commented Jul 18, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment