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 14:50

    that's probably about pricing model... ;)

    https://fontawesome.com/how-to-use/on-the-web/referencing-icons/basic-use

    Solid    Free           fas   <i class="fas fa-camera"></i> 
    Regular  Pro Required   far   <i class="far fa-camera"></i> 
    Light    Pro Required   fal   <i class="fal fa-camera"></i> 
    Brands   Free           fab   <i class="fab fa-font-awesome"></i>
    
    0 讨论(0)
  • 2020-12-12 14:50

    I found a solution.

    • Integrate fontawesome-all.css
    • At the end of file Search the second @font-face and replace

      font-family: 'Font Awesome 5 Free';

    With

    font-family: 'Font Awesome 5 FreeR';
    

    And replace:

    .far {
      font-family: 'Font Awesome 5 Free';
      font-weight: 400; }
    

    With

    .far {
      font-family: 'Font Awesome 5 FreeR';
      font-weight: 400; }
    
    0 讨论(0)
  • 2020-12-12 14:55

    npm i --save @fortawesome/fontawesome-free

    My Sccs:

    @import "~@fortawesome/fontawesome-free/scss/fontawesome";
    @import "~@fortawesome/fontawesome-free/scss/brands";
    @import "~@fortawesome/fontawesome-free/scss/regular";
    @import "~@fortawesome/fontawesome-free/scss/solid";
    @import "~@fortawesome/fontawesome-free/scss/v4-shims";
    

    It worked fine for me!

    0 讨论(0)
  • 2020-12-12 14:57

    Strangely you must put the 'font-weight: 900' in some icons so that it shows them.

    #mainNav .navbar-collapse .navbar-sidenav .nav-link-collapse:after {
      content: '\f107';
      font-family: 'Font Awesome\ 5 Free'; 
      font-weight: 900; /* Fix version 5.0.9 */
    }
    
    0 讨论(0)
  • 2020-12-12 14:57

    Strangely you have to include the font-family and the font-weight for it to work. Here is what worked for me:

    .second-section-header::after {
        content: "\f259";
        font-family: 'Font Awesome\ 5 Free';
        font-weight: 900;
    }
    

    From there, you can begin adding any styles that you want.

    Let's say:

    .second-section-header::after {
        content: "\f259";
        font-family: 'Font Awesome\ 5 Free';
        font-weight: 900;
        font-size: 100px;
        color: white;
        z-index: 1;
        position: absolute;
    }
    

    I hope this helps.

    0 讨论(0)
  • 2020-12-12 14:59

    The problem is in the font-weight.
    For Font Awesome 5 you have to use {font-weight:900}

    0 讨论(0)
提交回复
热议问题