Skip to content

Instantly share code, notes, and snippets.

@4lun
Last active August 29, 2015 13:56
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 4lun/9230692 to your computer and use it in GitHub Desktop.
Save 4lun/9230692 to your computer and use it in GitHub Desktop.
Auto generate icon sprite and classes from icon/ directory. Resulting icons will be have .i-<filename> classes. Needs to be placed on an i element or on an element that includes the .i class
@import "compass/utilities/sprites";
$icon: sprite-map("icon/*.png", $layout: smart);
i, .i {
display: inline-block;
vertical-align: middle;
background-repeat: no-repeat;
background-position: top left;
background-image: $icon;
.lt-ie8 & {
display: inline;
}
}
@each $i in sprite_names($icon){
.i-#{$i}{
@include sprite-dimensions($icon, $i);
background-position: sprite-position($icon, $i);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment