0

I have the following code and from it, I'd really like to help me with the following:

Why are the icons not showing up (it only shows a square)? I used the same code with Font Awesome 4.7.0 and it works fine. However, it does not for this version (5.11.2).

Thanks in advance for your help!

$(document).ready(function() {
  $('.toggle').click(function() {
    $('.toggle').toggleClass('active');
    $('.toggle-content').toggleClass('active');
  });
});
.hidden {
  overflow: hidden;
}

.container {
  width: 100%;
  height: 1000px;
  margin: 0 auto;
  background-color: #eee;
}

.wrapper {
  background-color: pink;
  position: relative;

  display: flex;
  align-items: center;
}

.toggle {
  display: block;
  width: 20px;
  height: 20px;
  float: left;
  cursor: pointer;
  color: white;
  text-align: center;
  background-color: green;
  margin: 10px;

  &:before {
    content: '\f085'; // fas fa-cogs
        font-family: fontAwesome;
  }
}

.toggle.active {
  background-color: red;

  &:before {
    content: '\f00d'; //fas fa-times
  } 
}

.toggle-content {
  display: none;
}

.toggle-content.active{
  display: block;
  background-color: white;
  border: 1px solid black;
  position: absolute;
  top: 40px;
  left: 0;
}

<div class="container">
  <div class="wrapper">
    <div class="toggle"></div>
    <div class="toggle-content">
      <p>Some content</p>
    </div>
  </div>
</div>

Here's the link to my CodePen in case you find it easier: https://codepen.io/fergos2/pen/yLLgBRq

P.S.: I am using SCSS as a CSS preprocessor and the CSS link to font-awesome is included in my CodePen.

GBeck
  • 392
  • 7
  • 20

1 Answers1

1
.toggle::before {
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    content: "\f007";
}

Use double colons for using before.

https://fontawesome.com/how-to-use/on-the-web/advanced/css-pseudo-elements

Amanjot Kaur
  • 2,028
  • 4
  • 18
  • 33