Created
November 27, 2014 13:12
-
-
Save mohamnag/7714351ca07dd6bfa71a to your computer and use it in GitHub Desktop.
using a font for icons
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.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