Skip to content

Instantly share code, notes, and snippets.

@kenwoodworth
Created October 11, 2012 21:34
Show Gist options
  • Save kenwoodworth/3875624 to your computer and use it in GitHub Desktop.
Save kenwoodworth/3875624 to your computer and use it in GitHub Desktop.
A mixin to dynamically generate ::before syntax for icons.
@mixin before-icon($icon, $icon-hover:false) {
position: relative;
z-index: 1;
&:before {
content: '';
@extend .icon-#{$icon};
display: block;
height: icon-sprite-height($icon);
left: 0;
margin-top: -(icon-sprite-height($icon)/2);
position: absolute;
top: 50%;
width: icon-sprite-width($icon);
z-index: -1;
}
@if($icon-hover) {
&:hover {
&:before {
@extend .icon-#{$icon-hover};
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment