字体真棒图标无法在CSS中用作内容

Pau*_*ula 2 html5 css3 font-awesome

我知道SO中有很多类似的问题,但是由于某种原因,提供的答案对我不起作用。我本来要使用这个字体超棒的图标,但不会显示。当我尝试其他图标时,它们会起作用。我一直在关注本文档。

现在是这样显示的: 在此处输入图片说明

.input-validation-error input {
  border: 2px solid #f46262;
}

.input-validation-error input[type="text"] {
  position: relative;
}

.input-validation-error::before {
  font-family: "Font Awesome 5 Free";
  color: red;
  position: relative;
  content: "\f06a";
}
Run Code Online (Sandbox Code Playgroud)
<!-- FONT AWESOME -->
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">

<form class="registration-form">
  <div class="form-group input-validation-error">
    <input type="text" class="form-control" id="formGroupExampleInput" placeholder="Nombre de usuario">
  </div>
</form>
Run Code Online (Sandbox Code Playgroud)

Hug*_*ira 5

您必须设置font-weight属性。您可以尝试一下,它现在应该可以工作:

.input-validation-error::before {
    font-family: "Font Awesome 5 Free";
    color: red;
    position: relative;
    content: "\f06a";
    font-weight: 900;
}
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

  • 感叹号图标为实心样式(您发布的第一个链接显示了这一点)。在您发布的第二个链接中,说明中提到了`font-weight`属性“ _Set the font-weight:900(Solid),400(Regular or Brands),300(Light)_”。 (2认同)