In font awesome 4 you could easily apply an icon to a :before/:after element using CSS.
Is the same possible with the new font awesome 5 JS/SVG implementation? As from what i can see this requires the relevant tag to exist in html which isn't always practical e.g. you have a CMS and want to apply an icon to all user created content <li>
elements
I know in FA5 you can still use the old css/webfonts but it would be nice if the same functionality was available in the recommended method of using JS
Add styling to element that will contain the pseudo-element to support positioning. Set the font-family to Font Awesome 5 Duotone , the font-weight to 900 , and add positioning styles for the pseudo-element. Set the default opacity levels and colors for each layer of the duotone icon.
To use the Free Font Awesome 5 icons, you can choose to download the Font Awesome library, or you can sign up for an account at Font Awesome, and get a code (called KIT CODE) to use when you add Font Awesome to your web page.
It's not backwards compatible.
Specifying the proper font-weight
seems key to have some of the symbols displayed properly (and not "□□□" instead).
font-weight
has to be:
400
for Regular
and Brands
symbols900
for Solid
symbols300
for Light
symbols I.e. if you use Font-Awesome with CSS + Webfonts, a CSS-only solution is:
@import url("font-awesome/css/fontawesome-all.min.css"); /* FA CSS import */ /* ... */ .class:before { /* >> Symbol you want to use: */ content: "\f16c"; /* >> Name of the FA free font (mandatory), e.g.: - 'Font Awesome 5 Free' for Regular and Solid symbols; - 'Font Awesome 5 Pro' for Regular and Solid symbols (Professional License); - 'Font Awesome 5 Brand' for Brands symbols. */ font-family: 'Font Awesome 5 Free'; /* >> Weight of the font (mandatory): - 400 for Regular and Brands symbols; - 900 for Solid symbols; - 300 for Light symbols. */ font-weight: 900; /* >> Optional styling: */ display: inline-block; /* ... */ }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With