iconfont Demo

  • love-桃心
    
  • love
    
  • icon_love
    
  • money
    
  • money-asp
    
  • money-currency-converter
    
  • money-rmb-symbol
    
  • money-red-packet-fill
    
  • money-funds
    
  • 打赏
    
  • 点赞
    
  • 点赞
    
  • 点赞
    
  • 点赞
    
  • 点赞-已点赞
    
  • 点赞-已点赞
    
  • 点赞(已点赞)
    
  • 点赞收藏
    
  • 点赞收藏-copy
    
  • 点赞-填充
    
  • 点赞
    
  • 点赞
    
  • 打赏
    
  • 打赏
    
  • 点赞
    
  • 打赏
    
  • 点赞-copy
    

Unicode 引用


Unicode 是字体在网页端最原始的应用方式,特点是:

  • 支持按字体的方式去动态调整图标大小,颜色等等。
  • 默认情况下不支持多色,直接添加多色图标会自动去色。

注意:新版 iconfont 支持两种方式引用多色图标:SVG symbol 引用方式和彩色字体图标模式。(使用彩色字体图标需要在「编辑项目」中开启「彩色」选项后并重新生成。)

Unicode 使用步骤如下:

第一步:拷贝项目下面生成的 @font-face

@font-face {
  font-family: 'iconfont';
  src: 
       url('data:application/x-font-woff2;charset=utf-8;base64,d09GMgABAAAAABQ0AAsAAAAAIzQAABPkAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHFQGYACGZAqybKlDATYCJANsCzgABCAFhGcHgmwbkx2joqxTZiH7ywOejJd5KYIJogiBasXRDvsEL761GqJCH8sQy/2bOd1c/8pBUh9KyfP0y3fn7tvfu4+KqkJlfELpGvU9lkhUk0jNIFRVS2bQ6Azx2/wjogQFHlI2oo1FTcLGrrUxXSorWbkoK5b5U1dtLMNFpUtzmR8AqROmHRAqtCul5UuXS+Ffi81OqrX5/4BUZJMxrqlm0twUfTCnJhUOpCQjQ6BA6ZwRoKEwIM5Hvqd89zMkdYcXp4gDYMP8z6U26QBIFTJCYWtF4OgnP/fyj/9Rm3LKuWK6EqsBGrkppKQApAasNotCTRgWRtdOCD3np2bXlJfXklmc2jg+v9/8XXTRVm8cZYiN/d7XYiIC6PMRDn599/IOU0dXNKxB0i4OEBbPMY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bYgvtQHoAhDFEkVnYCZ/esYBhJCZp0V4vX4NCqyhlYDWh7PLLnAomqPBsZ6+qTBnbHhxczMpQ8GzRR+s2W6nNyocAIRLZ+zzGBfH2MyWjVHV83bnIprNhVhCDOOPNvf0lvUm8892HCBulTBi9GPGkNJ5d7kzTuUXBownSLFEI9cPh8I0gk/4r4gh+MFQHvgfrfoyNrBu8PEO/jodEHDBu5fO2Hq3QYj48EeLgvpX/LXddFGP3VRd9/9HenBRP9xW9/BOxuiFD6/UcnMqreTMAdyXrh/z6LL+gE5rjLqjxxpkgAtpdF2qJfOVJYop0lUO9HhEVRHH7pkuhl3vvOOeFo0XydeBBoeJ/7mj753x3/hZH2x5HRrVZupi44zRH1W0vyhkkhRmv79hDJoQYATG6jmCyrhb3efLXQuZJDB7fex5IV6OsnAN8eEubu1k9cMJu+x4iMkKpg8KkCCyLrRW5UC4Ev1YYVRvW5M3Q+wDBZP1jdA5yYu6FgqLZQcGT/UQhUp0jkomsUCttTCo3qN4WXksmeEchSeM3oCgbK66rEJx3KLu7lvmJU5S4/y/hENgnS1KaXTzL3HjVyHgamjrZEQhUyFepuOzjMc1IlU4q+2LFIebTuXUIzsH0q4BpDLrH3DCgFuseW8xEtbF3iX94rFKnkXMxIfmJmFJYEFNUPoVoZyHtBM9VaE22VWmRLNcEhZQImoPBF4xWjXM8iymT6/VLIJ2xlHErpiDdprYRVsMsXi5khGHd1au0fAk9JnVba6aSb3odY9pPtHI4zyTS00MMIM6ywwwk3vDiFHwH8kWoUl9pEDwbCpn3M1uAE0tgdzbZcU674ar9iRu2r+UjXyCI48zQfF55lumeI8sVERxhYpetnKFaY5Pk4JV9Y6cD0abfhIHF1Txx1Q5ubWN++pa7anA1Z3QStzz24N2eIFRf0Bz0uILvKfkw66hcqc1V2+4vMlmnfSZDb9u2IfwcAAAAA') format('woff2'),
       url('iconfont.woff?t=1684141510245') format('woff'),
       url('iconfont.ttf?t=1684141510245') format('truetype');
}

第二步:定义使用 iconfont 的样式

.iconfont {
  font-family: "iconfont" !important;
  font-size: 16px;
  font-style: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

第三步:挑选相应图标并获取字体编码,应用于页面

<span class="iconfont">&#x33;</span>

"iconfont" 是你项目下的 font-family。可以通过编辑项目查看,默认是 "iconfont"。

  • love-桃心
    .icon-lovetaoxin
  • love
    .icon-love1
  • icon_love
    .icon-love2
  • money
    .icon-money
  • money-asp
    .icon-money-asp
  • money-currency-converter
    .icon-money-currency-converter
  • money-rmb-symbol
    .icon-money-rmb-symbol
  • money-red-packet-fill
    .icon-money-red-packet-fill
  • money-funds
    .icon-money-funds
  • 打赏
    .icon-ds
  • 点赞
    .icon-dianzan
  • 点赞
    .icon-dianzan11
  • 点赞
    .icon-dianzan2
  • 点赞
    .icon-dianzan1
  • 点赞-已点赞
    .icon-dianzan-yidianzan
  • 点赞-已点赞
    .icon-dianzan-yidianzan1
  • 点赞(已点赞)
    .icon-dianzanyidianzan
  • 点赞收藏
    .icon-dz1
  • 点赞收藏-copy
    .icon-dz2
  • 点赞-填充
    .icon-dianzan-tianchong
  • 点赞
    .icon-top
  • 点赞
    .icon-dianzan5
  • 打赏
    .icon-ds2
  • 打赏
    .icon-ds4
  • 点赞
    .icon-dianzan3
  • 打赏
    .icon-ds3
  • 点赞-copy
    .icon-dianzan4

font-class 引用


font-class 是 Unicode 使用方式的一种变种,主要是解决 Unicode 书写不直观,语意不明确的问题。

与 Unicode 使用方式相比,具有如下特点:

  • 相比于 Unicode 语意明确,书写更直观。可以很容易分辨这个 icon 是什么。
  • 因为使用 class 来定义图标,所以当要替换图标时,只需要修改 class 里面的 Unicode 引用。

使用步骤如下:

第一步:引入项目下面生成的 fontclass 代码:

<link rel="stylesheet" href="./iconfont.css">

第二步:挑选相应图标并获取类名,应用于页面:

<span class="iconfont icon-xxx"></span>

" iconfont" 是你项目下的 font-family。可以通过编辑项目查看,默认是 "iconfont"。

  • love-桃心
    #icon-lovetaoxin
  • love
    #icon-love1
  • icon_love
    #icon-love2
  • money
    #icon-money
  • money-asp
    #icon-money-asp
  • money-currency-converter
    #icon-money-currency-converter
  • money-rmb-symbol
    #icon-money-rmb-symbol
  • money-red-packet-fill
    #icon-money-red-packet-fill
  • money-funds
    #icon-money-funds
  • 打赏
    #icon-ds
  • 点赞
    #icon-dianzan
  • 点赞
    #icon-dianzan11
  • 点赞
    #icon-dianzan2
  • 点赞
    #icon-dianzan1
  • 点赞-已点赞
    #icon-dianzan-yidianzan
  • 点赞-已点赞
    #icon-dianzan-yidianzan1
  • 点赞(已点赞)
    #icon-dianzanyidianzan
  • 点赞收藏
    #icon-dz1
  • 点赞收藏-copy
    #icon-dz2
  • 点赞-填充
    #icon-dianzan-tianchong
  • 点赞
    #icon-top
  • 点赞
    #icon-dianzan5
  • 打赏
    #icon-ds2
  • 打赏
    #icon-ds4
  • 点赞
    #icon-dianzan3
  • 打赏
    #icon-ds3
  • 点赞-copy
    #icon-dianzan4

Symbol 引用


这是一种全新的使用方式,应该说这才是未来的主流,也是平台目前推荐的用法。相关介绍可以参考这篇文章 这种用法其实是做了一个 SVG 的集合,与另外两种相比具有如下特点:

  • 支持多色图标了,不再受单色限制。
  • 通过一些技巧,支持像字体那样,通过 font-size, color 来调整样式。
  • 兼容性较差,支持 IE9+,及现代浏览器。
  • 浏览器渲染 SVG 的性能一般,还不如 png。

使用步骤如下:

第一步:引入项目下面生成的 symbol 代码:

<script src="./iconfont.js"></script>

第二步:加入通用 CSS 代码(引入一次就行):

<style>
.icon {
  width: 1em;
  height: 1em;
  vertical-align: -0.15em;
  fill: currentColor;
  overflow: hidden;
}
</style>

第三步:挑选相应图标并获取类名,应用于页面:

<svg class="icon" aria-hidden="true">
  <use xlink:href="#icon-xxx"></use>
</svg>