0

I am trying to include font awesome icon through CSS pseudo elements, but it never appears. I already tried to set the font family to "Font Awesome 5 Free", "Font Awesome 5 Brand" and adjust font weights to different values but none of them work for me. What did I miss?

My CSS

.form-field::before{
    font-family: "Font Awesome 5 Brands";
    content: "\f057";
    position: absolute;
    font-weight: 900;
    font-size: 40px;
    z-index: 200;
}

.form-field::after{
    font-family: "Font Awesome 5 Free";
    content: "\f057";
    position: absolute;
    font-weight: 900;
    font-size: 40px;
    z-index: 200;
}

CDN

<link href="https://use.fontawesome.com/releases/v5.5.0/css/all.css" rel="stylesheet">
Alexander Nied
  • 12,804
  • 4
  • 25
  • 45
Dave Yu
  • 315
  • 4
  • 15

1 Answers1

1

Here is the working example

.wrapper {
  width: 200px;
  position: relative;
}
.wrapper::before{
    font-family: "Font Awesome 5 Brands";
    content: "\f057";
    position: absolute;
    left: 0;
    font-weight: 900;
    font-size: 40px;
    z-index: 200;
}

.wrapper::after{
    font-family: "Font Awesome 5 Free";
    content: "\f057";
    position: absolute;
    top: 5px;
    right: 0;
    font-weight: 900;
    font-size: 40px;
    z-index: 200;
}

input {
  height: 50px;
  width: 100%;
}
<link href="https://use.fontawesome.com/releases/v5.5.0/css/all.css" rel="stylesheet">
<div class="wrapper">
  <input class="form-field" type="text">
</div>