首先在阿里巴巴矢量图库里面找到自己想要的图标
然后添加到购物车,它会让你添加到一个项目中
然后在我的项目中管理
点击查看在线链接
将这样的一段代码添加到自己所需图标的css文件中
@font-face { font-family: \'iconfont\'; /* project id 524168 */ src: url(\'//at.alicdn.com/t/font_524168_p6patg7f4svjwcdi.eot\'); src: url(\'//at.alicdn.com/t/font_524168_p6patg7f4svjwcdi.eot?#iefix\') format(\'embedded-opentype\'), url(\'//at.alicdn.com/t/font_524168_p6patg7f4svjwcdi.woff\') format(\'woff\'), url(\'//at.alicdn.com/t/font_524168_p6patg7f4svjwcdi.ttf\') format(\'truetype\'), url(\'//at.alicdn.com/t/font_524168_p6patg7f4svjwcdi.svg#iconfont\') format(\'svg\'); }
然后将字体图标引用进来
.iconfont{ font-family: \'iconfont\'; font-size: 100px; }
然后将字体图标引用进来,然后会发现图标出现不了
解决办法:将引入字体图标的那段代码的url中最前面都加上http:
如下所示
@font-face { font-family: \'iconfont\'; /* project id 524168 */ src: url(\'http://at.alicdn.com/t/font_524168_p6patg7f4svjwcdi.eot\'); src: url(\'http://at.alicdn.com/t/font_524168_p6patg7f4svjwcdi.eot?#iefix\') format(\'embedded-opentype\'), url(\'http://at.alicdn.com/t/font_524168_p6patg7f4svjwcdi.woff\') format(\'woff\'), url(\'http://at.alicdn.com/t/font_524168_p6patg7f4svjwcdi.ttf\') format(\'truetype\'), url(\'http://at.alicdn.com/t/font_524168_p6patg7f4svjwcdi.svg#iconfont\') format(\'svg\'); }
之后就可以使用图标了 。
使用方法如下:
<span class="iconfont"></span>直接使用对应的图标的编号就可以