【发布时间】:2018-11-13 18:20:24
【问题描述】:
我目前对在 CSS 伪元素中使用图标感到困惑。 fontawesome 有 4 种字体系列:Font Awesome 5 Free、Font Awesome 5 Solid、Font Awesome 5 Brands、Font Awesome 5 Regular
这里是 HTML:
<h1>Hello</h1>
案例一
我使用这个图标:https://fontawesome.com/icons/twitter?style=brands
如您所见,它是一个 brands 图标,所以 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;
}
它工作!
案例 2
我使用这个图标:https://fontawesome.com/icons/phone?style=solid
如您所见,它是一个 solid 图标,所以 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;
}
不工作!
我做错了什么?
我们如何知道何时使用正确的字体系列?
【问题讨论】:
-
如有疑问,请查看您下载的
fa-phonecss 类的 fontawesome.css 文件。
标签: css fonts font-awesome pseudo-element font-awesome-5