使用svg制作字体图标

###1.访问链接转换svg字体的网站 https://icomoon.io/

###2.导入SVG图标


###3.选中你要转换的SVG图标



###4.设置信息 设置icon名称以及相关信息


生成例子以及相关样式代码:

####5.主要是生成的css文件 style.css

@font-face {
  font-family: 'icomoon';
  src:  url('fonts/icomoon.eot?xhzg4r');
  src:  url('fonts/icomoon.eot?xhzg4r#iefix') format('embedded-opentype'),
    url('fonts/icomoon.ttf?xhzg4r') format('truetype'),
    url('fonts/icomoon.woff?xhzg4r') format('woff'),
    url('fonts/icomoon.svg?xhzg4r#icomoon') format('svg');
  font-weight: normal;
  font-style: normal;
}

[class^="icon-"], [class*=" icon-"] {
  /* use !important to prevent issues with browser extensions that change fonts */
  font-family: 'icomoon' !important;
  speak: none;
  font-style: normal;
  font-weight: normal;
  font-variant: normal;
  text-transform: none;
  line-height: 1;

  /* Better Font Rendering =========== */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.icon-appicon:before {
  content: "\e902";
}

复制代码

把生成的fonts里面的所有文件拷贝到你需要的开发环境


###6.实际调用 只需要给相关的类名即可以,类名就是之前生成的时候你编写的名字前面加上icon-,如果没有改,就是你svg文件的名字。

<span class="icon-appicon"></span>
复制代码

转载于:https://juejin.im/post/5a32129d6fb9a044fc44c186

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值