Font awesome is not showing icon

后端 未结 30 1096
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-30 06:03

I am using Font Awesome and do not wish to add CSS with HTTP. I downloaded Font Awesome and included it in my code, yet Font Awesome is showing a bordered square box instead

相关标签:
30条回答
  • 2020-11-30 06:42

    In my case i made the following mistake in my css code.

    *{
        font-family: 'Open Sans', sans-serif !important;
    }
    

    This will override all font family rules for the entire page. My solution was to move the code to body like so.

    body{
        font-family: 'Open Sans', sans-serif;
    }
    

    NB: Whenever you use the !important flag in css, any other css rule declared of the same type on the same element will get overriden.

    0 讨论(0)
  • 2020-11-30 06:42

    Open your font-awesome.css theres code like :

    @font-face {
      font-family: 'FontAwesome';
      src: url('../fonts/fontawesome-webfont.eot?v=4.5.0');
      src: url('../fonts/fontawesome-webfont.eot?#iefix&v=4.5.0') format('embedded-opentype'), url('../fonts/fontawesome-webfont.woff2?v=4.5.0') format('woff2'), url('../fonts/fontawesome-webfont.woff?v=4.5.0') format('woff'), url('../fonts/fontawesome-webfont.ttf?v=4.5.0') format('truetype'), url('../fonts/fontawesome-webfont.svg?v=4.5.0#fontawesomeregular') format('svg');
      font-weight: normal;
      font-style: normal;
    }
    

    you must have folder like :

    font awesome -> css
     -> fonts
    

    or the easiest way :

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
    
    0 讨论(0)
  • 2020-11-30 06:42

    <script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/js/all.js" integrity="sha256-2JRzNxMJiS0aHOJjG+liqsEOuBb6++9cY4dSOyiijX4=" crossorigin="anonymous"></script>

    0 讨论(0)
  • 2020-11-30 06:42

    you need to put font-awesome file in css folder and change

    href="../css/font-awesome.css" to href="css/font-awesome.css"

    One more thing You can Replace this Font-awesome css File And and try this one

    .social-media{
      list-style-type: none;
      padding: 0px;
      margin: 0px;
    }
    
    .social-media li .fa{ 
      background: #fff;
      color: #262626;
      width: 50px;
      height: 50px;
      border-radius: 50%;
      text-align:center;
      line-height:50px; 
    }
    
    .social-media .fa:hover { 
      box-shadow: 5px 5px 5px #000; 
    }
    
    .social-media .fa.fa-twitter:hover{
      background:#55acee;
      color:#fff;
     
    }
    
    .social-media .fa.fa-facebook:hover{
      background:#3b5998;
      color:#fff;
    }
    <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
    
    <ul class="social-media">
      <li><i class="fa fa-twitter fa-2x"></i></li>
      <li><i class="fa fa-facebook fa-2x"></i></li>
     
    </ul>

    0 讨论(0)
  • 2020-11-30 06:44

    Be aware that the new version (5) of font awesome uses "fas" or "fab" instead of "fa" prefix.

    Quoted from their website:

    The fa prefix has been deprecated in version 5. The new default is the fas solid style and the fab style for brands.

    This is why my fonts were showing blank squares. Now fixed.

    Example code:

    <a class="nav-link" href="//www.facebook.com/xxx" target="_blank"><i class="fab fa-facebook-f"></i></a>
    

    See: https://fontawesome.com/icons/facebook-f?style=brands

    0 讨论(0)
  • 2020-11-30 06:44

    It's something to do with v5, some of the icons don't work with older versions.

    This link worked for me!

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css">
    
    0 讨论(0)
提交回复
热议问题