I'm currently confused in using the icon in CSS pseudo-elements. There are 4 kind of font-family for fontawesome : Font Awesome 5 Free
, Font Awesome 5 Solid
, Font Awesome 5 Brands
, Font Awesome 5 Regular
Here is the HTML :
<h1>Hello</h1>
Case 1
I use this icon : https://fontawesome.com/icons/twitter?style=brands
As you can see, its a brands
icon, so font-family : Font Awesome 5 Brands
h1:before {
display: inline-block;
font-style: normal;
font-variant: normal;
text-rendering: auto;
-webkit-font-smoothing: antialiased;
content: "f099"; /* TWITTER ICON */
font-family: "Font Awesome 5 Brands";
font-weight: 400;
}
IT WORKS!
Case 2
I use this icon : https://fontawesome.com/icons/phone?style=solid
As you can see, its a solid
icon, so font-family : Font Awesome 5 Solid
h1:before {
display: inline-block;
font-style: normal;
font-variant: normal;
text-rendering: auto;
-webkit-font-smoothing: antialiased;
content: "f095"; /* PHONE ICON */
font-family: "Font Awesome 5 Solid";
font-weight: 900;
}
DOESN'T WORK!
What did i do wrong?
How do we know when to use the correct font-family?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…