html - 从 css 添加很棒的字体

标签 html css

我在我的 html 中添加了很棒的字体,但我只是想如果我通过 css 添加它会更好,否则如果我想在多个标签中添加它,我将不得不添加每个标签,如我的 html 代码所示:

<ul>
    <li><strong><p>SERVICES</p></strong></li>
    <li><a href="#"><i class="fa fa-caret-right" aria-hidden="true"></i> Financial</a></li>
    <li><a href="#"><i class="fa fa-caret-right" aria-hidden="true"></i> Medical</a></li>
    <li><a href="#"><i class="fa fa-caret-right" aria-hidden="true"></i> Insurance</a></li>   
</ul>

如何从我的样式表中添加这些图标?

最佳答案

您可以通过在 CSS 中插入 FontAwesome 图标 content 属性来做到这一点。

例如:

a:before { 
    font-family: FontAwesome;
    content: "\f095";
}

DEMO

如果你不知道如何获取图标内容,你可以从这里复制:

LINK

然后你可以将这个图标分配给特定的 a 标签,考虑使用 a class 来让它更具体:

a.class_name:before { 
    font-family: FontAwesome;
    content: "\f095";
}

关于html - 从 css 添加很棒的字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37481452/

相关文章:

html - 使所有 <li> 与最宽的宽度相同

html - 当 flexbox 元素以列模式包装时,容器不会增加其宽度

jquery - jQuery 中的水平滚动菜单宽度

html - 2 个 div 在 div 中向左浮动。 2 个这样的 div 在另一个 div 中向左浮动 - 高度问题

html - Bootstrap 4 导航栏下拉高度不同

javascript - 页面宽度比视口(viewport)宽,空白在右边

javascript - 按钮点击伪装

html - 内部 Div 的宽度比外部 div 的宽度大

javascript - 可以指向以 javascript ://execute any code? 开头的 URL 的链接吗

html - CSS 对齐失败和 Div 高度错误