Created
August 5, 2013 15:54
-
-
Save chipcullen/6157025 to your computer and use it in GitHub Desktop.
My power duo for dealing with icons and SASS - an extendable %icon that references your icon font. The mixin then allows you to specify the content (the unicode string for the icon), and optionally 'before' or 'after' which creates the respective pseudo element. #icons #iconfonts #scss
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
%icon { | |
font-family: $icon-font; //set as a variable - it's whatever your icon font name is | |
speak: none; | |
font-weight: normal; | |
font-variant: normal; | |
text-transform: none; | |
line-height: 1; | |
-webkit-font-smoothing: antialiased; | |
} | |
@mixin icon($content, $position:"") { | |
@if $position == "" { | |
@extend %icon; | |
content: $content; | |
} @else if $position == before { | |
&::before { | |
@extend %icon; | |
content: $content; | |
} | |
} @else if $position == after { | |
&::after { | |
@extend %icon; | |
content: $content; | |
} | |
} | |
} | |
//usage: | |
//.foo { | |
// @include icon('\e001', before); | |
//} | |
//or | |
//.bar { | |
// &::after { | |
// @include icon('\e001'); | |
// -- other styles | |
// } | |
//} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment