Skip to content

Instantly share code, notes, and snippets.

@mohamnag
Created November 27, 2014 13:12
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 mohamnag/7714351ca07dd6bfa71a to your computer and use it in GitHub Desktop.
Save mohamnag/7714351ca07dd6bfa71a to your computer and use it in GitHub Desktop.
using a font for icons
/*
This adds the desired character as an overlayed icon vertically and horizontally
centered on the element.
This uses the :after pseudo element so this element is not usable afterwards.
*/
@mixin fontIcon($font, $char, $size) {
&:after {
// character related to the desired icon
content: $char;
font-family: $font;
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
display: block;
position: relative;
font-size: $size;
top: 50%;
line-height: 1;
margin-top: - $size / 2;
left: 50%;
width: $size;
margin-left: - $size / 2;
}
}
.a-class{
@include fontIcon('TheIconFont', "\e618", 2rem);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment