打开icomoon,选择想要的图标
在Selection中生成这些图标,在Font中下载生成压缩包,并解压。
将fonts文件夹与html文件放在同一个目录下。
复制图标方框位置对图标进行复制。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
/*声明 要在样式中声明字体,表明这是我们自己定义的字体*/
@font-face {
font-family: 'icomoon';
src: url('fonts/icomoon.eot?7kkyc2');
src: url('fonts/icomoon.eot?7kkyc2#iefix') format('embedded-opentype'),
url('fonts/icomoon.ttf?7kkyc2') format('truetype'),
url('fonts/icomoon.woff?7kkyc2') format('woff'),
url('fonts/icomoon.svg?7kkyc2#icomoon') format('svg');
font-weight: normal;
font-style: normal;
}
/*给盒子使用字体*/
span,div{
font-family: 'icomoon';
font-size: 60px;
color:red;
}
</style>
</head>
<body>
<span></span>
<div></div>
</body>
</html>
注意要对路径等进行声明,路径要正确。
过程中,可能会设计icomoon字体图标添加的问题,及字体图标的追加,正确操作步骤如下:
①选择要追加的图标,点击页面左上方Import Icons按钮。
②追加完成后,点击Generate Font对图标进行下载并解压。
③用新的icomoon文件替代之前的icomoon文件,并将新的fonts文件移动到与html文件同目录下,完成。