这里使用的是Font Awesome图标字体库
通过伪元素设置图标字体:
1.找到要设置图标的元素通过before或after选中
2.在content中设置字体的编码
3.设置字体的样式
fab:
font-family: ‘Font Awesome 5 Brands’
fa,fas:
font-family: ‘Font Awesome 5 Free’;
font-weight: 900;
Demo:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="./icon/css/all.css">
<title>图标字体</title>
<style>
div{
margin:100px 500px;
}
p::before{
/*图标字体对应的unicode编码
比如对应的图标类:fa fa-heartbeat
*/
/* content:'\f21e'; */
/* content:'\f368'; */
content:'\f0f8';
/* font-family:'Font Awesome 5 Brands'; */
/*在all.css中查找图标类(fa,fas,fab)的样式*/
font-family:'Font Awesome 5 Free';
font-weight: 900;
color:green;
margin-right:10px;
}
</style>
</head>
<body>
<div>
<!-- <i class="fa fa-heartbeat"></i> -->
<p>今夕何夕兮</p>
<p>搴舟中流</p>
<p>今日何日兮</p>
<p>得与王子同舟</p>
<!-- <i class="fa fa-wheelchair"></i> -->
<!-- 通过实体来使用图标字体
&#x图标编码
包含元素要添加对应的图标类
-->
<span class="fa"> </span>
</div>
</body>
</html>