如何将Font Awesome图标嵌入到外部CSS样式表中。
对于Font Awesome 5和免费图标---
#preview .buttons .ok {
border: 1px solid #F5F5F5;
border-radius: 4px;
width: 28px;
height: 28px;
font-size: 20px;
}
.ok:before {
content: "\e900";
display: inline-block;
font-family: "Font Awesome 5 Free";
font-weight: 700;
font-size: inherit;
text-rendering: auto;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
transform: translate(0, 0);
}
现在尝试。.
答案 0 :(得分:2)
\e900
在awesome字体的图标中不存在...
它与他人(例如\f2b9
)很好地工作
请在此处查看图标并将unicode复制到css:https://fontawesome.com/icons?d=gallery
然后将以下链接放在您的head
标记中
#preview .buttons .ok {
border: 1px solid #F5F5F5;
border-radius: 4px;
width: 28px;
height: 28px;
font-size: 20px;
}
.ok:before {
content: "\f2b9";
display: inline-block;
font-family: "Font Awesome 5 Free";
font-weight: 900;
font-size: inherit;
text-rendering: auto;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
transform: translate(0, 0);
}
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.1.1/css/all.css" integrity="sha384-O8whS3fhG2OnA5Kas0Y9l3cfpmYjapjI0E4theH4iuMD+pLhbf6JI0jIMfYcK3yZ" crossorigin="anonymous">
<div id='preview'>
<div class='buttons'>
<div class='ok'></div>
</div>
</div>
答案 1 :(得分:0)
对于Font Awesome 5和免费图标---
border: 1px solid #F5F5F5;
border-radius: 4px;
width: 28px;
height: 28px;
font-size: 20px;
content: "\e900";
display: inline-block;
font-family: "Font Awesome 5 Free";
font-weight: 700;
font-size: inherit;
text-rendering: auto;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
transform: translate(0, 0);
注意:对于超棒的5个免费字体图标,必须在外部CSS文件中添加此标记。
现在尝试。
答案 2 :(得分:-1)
为了包括Font Awesome,您需要在HTML文件中包括<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.1.1/css/all.css" integrity="sha384-O8whS3fhG2OnA5Kas0Y9l3cfpmYjapjI0E4theH4iuMD+pLhbf6JI0jIMfYcK3yZ" crossorigin="anonymous">
,然后将其用于CSS。看看有关字体真棒的官方文档。