html - 将很棒的字体图标嵌入到外部 css 文件中

标签 html css bootstrap-4 icons font-awesome

如何将 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);
}

现在尝试一下..

最佳答案

\e900 不存在于 font 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>

关于html - 将很棒的字体图标嵌入到外部 css 文件中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51399884/

相关文章:

javascript - Div 固定和不固定在两个绝对 div 之间切换

css - Bootstrap 登录颜色组件

html - 相对于图像的特定部分在响应图像上定位文本

html - 删除/添加不适用于 index.php 的代码

javascript - Bootstrap,侧边栏没有响应

jquery - 使用jquery高度动态获取两个嵌套框的高度?

javascript - bootstrap vue progress 的独立颜色

html - 背景色保持白色

html - 微数据 schema.org : how to mix together schemas?

javascript - 如果div向下滑动则使div下面的所有内容都向下移动