Font Awesome 5 font-family issue

前端 未结 16 2759
深忆病人
深忆病人 2020-12-12 14:31

I integrated Font Awesome 5 in a project with bootstrap 4. When I recall a font via CSS it does not work. with Font Awesome 4 the code was as follows:

#mainN         


        
相关标签:
16条回答
  • 2020-12-12 15:00

    If you are using SVG with JavaScript you need to enable this because it's disabled by default. Use

    <script data-search-pseudo-elements ... >

    inside your script tag.

    0 讨论(0)
  • 2020-12-12 15:01

    Requiring 900 weight is not a weirdness but a intentional restriction added by FontAwesome (since they share the same unicode but just different font-weight) so that you are not hacking your way into using the 'solid' and 'light' icons, most of which are available only in the paid 'Pro' version.

    0 讨论(0)
  • 2020-12-12 15:05

    I had tried all above the solutions for Font Awesome 5 but it wasn't working for me. :(

    Finally, I got a solution!

    Just use font-family: "Font Awesome 5 Pro"; in your CSS instead of using font-family: "Font Awesome 5 Free OR Solids OR Brands";

    0 讨论(0)
  • 2020-12-12 15:06

    Since FontAwesome 5, you have to enable a new "searchPseudoElements" option to use FontAwesome icons this way:

    <script>
      window.FontAwesomeConfig = {
        searchPseudoElements: true
      }
    </script>
    

    See also this question: Font awesome 5 on pseudo elements and the new Font Awesome API: https://fontawesome.com/how-to-use/font-awesome-api

    Additionaly, change font-family in your CSS code to

    font-family: "Font Awesome 5 Regular";
    
    0 讨论(0)
提交回复
热议问题