Skip to content

Instantly share code, notes, and snippets.

@seb-thomas
Created August 11, 2016 16: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 seb-thomas/26a02619d581d64e1aadd7935b0af08e to your computer and use it in GitHub Desktop.
Save seb-thomas/26a02619d581d64e1aadd7935b0af08e to your computer and use it in GitHub Desktop.
// Assumes a vertical sprite sheet
$icon-size: 18px;
.icon {
display: inline-block;
background-repeat: no-repeat;
background-image: url(../images/sprite.png);
width: $icon-size;
height: $icon-size;
background-size: $icon-size;
vertical-align: middle;
}
$icons: alert angle-right arrow-down arrow-left arrow-right arrow-up close cog columns document filter flag grid new-tab restricted search tick trash zoom-in ;
@mixin icon-sprite($offset) {
$offset: $offset - 1;
background-position: left $icon-size*-$offset;
}
@for $i from 1 through length($icons) {
$icon: nth($icons, $i);
.icon-#{$icon} {
@include icon-sprite($i);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment