Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Font awesome icon does not show

I am working with Angular 4 in dev environment (localhost). I installed font awesome via npm and added:

"./node_modules/font-awesome/css/font-awesome.css",

to my styles scripts.

When I check my icon in browser, everything looks fine:

screenshot

But my icon does not appear on the page, just an empty square. What am I doing wrong?

like image 933
Milos Avatar asked Sep 08 '17 05:09

Milos


People also ask

Why is Font Awesome icon not showing up?

Make sure you're using the latest and greatest by updating your CDN code reference, updating your Font Awesome package via npm, or downloading a fresh copy of Font Awesome. You can check with version an icon was added to on its detail page (e.g. question-circle was added in Verion 1 but last updated in 5.0. 0).

How do I show Font Awesome icons?

You can place Font Awesome icons just about anywhere using the CSS Prefix fa and the icon's name. Font Awesome is designed to be used with inline elements (we like the <i> tag for brevity, but using a <span> is more semantically correct). icon If you change the font-size of the icon's container, the icon gets bigger.

Why are FAS FA icons not working?

make sure you have font-weight: 900 . you are using multiple classes fas fa-github btn btn-dark btn-lg if any of these does not have font-weight: 900 font will not show up. but if you are using fas with some other class like . btn it will over write font-weight: 900 and icon will not display.

How do I display Font Awesome icons in HTML?

You place Font Awesome icons by using the prefix fa and the icon's name.


2 Answers

its working code :

npm install font-awesome --save

add font-awesome link in .angular-cli.json :

"../node_modules/font-awesome/css/font-awesome.css"

in html file

<i class="fa fa-cog fa-spin"></i>
like image 147
Chandru Avatar answered Sep 30 '22 14:09

Chandru


If you're using the free version. Try this..

First Delete fortawesome registry & authToken

npm config delete "@fortawesome:registry"
npm config delete "//npm.fontawesome.com/:_authToken"

Then Install the package

npm install --save-dev @fortawesome/fontawesome-free

After Installing the package, Add below code in your angular.json file

   ......      
    "styles": [
    ......
    "node_modules/@fortawesome/fontawesome-free/css/all.css"
    ],
    "scripts": [
    ....
    "node_modules/@fortawesome/fontawesome-free/js/all.js"
    ],
    .....
    

Note: There were twice of those blocks (styles/scripts). Add to both

like image 34
Nithin mm Avatar answered Sep 30 '22 14:09

Nithin mm