• 
  • 步行
    
  • 刷新
    
  • 闹钟
    
  • 公交站牌
    
  • 更多
    
  • 微信好友
    
  • 
  • 起点
    
  • 编辑
    
  • 新东方-刷新图标
    
  • 删 除
    
  • 长箭头
    
  • 
  • 更多
    
  • 交通 公交车 看房团 大巴 面性
    
  • 一键
    
  • 
  • 刷新
    
  • 返回
    
  • 下 拉
    
  • 长箭头
    
  • 定位 位置
    
  • QQ
    
  • 
  • 变更
    
  • 个人中心 我的 人物 标准头 面性
    
  • 关于
    
  • 回家
    
  • 定位
    
  • 终点
    
  • 意见
    
  • 换乘
    
  • 提醒
    
  • 下 拉
    
  • 收 藏
    
  • 菜单
    
  • 定位
    
  • 首页-选中
    
  • 历史
    
  • 设 置
    
  • 分 享
    
  • 上班
    
  • 上班
    
  • 地图
    
  • 前进
    
  • 定位 位置
    
  • 加载
    
  • 地图
    
  • 公告
    
  • 返回
    
  • 公车管理
    
  • 微博
    
  • 变更
    
  • 信息
    
  • 搜索
    
  • 朋友圈
    
  • 警告
    
  • 更多
    
  • 更多
    

Unicode 引用


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

  • 兼容性最好,支持 IE6+,及所有现代浏览器。
  • 支持按字体的方式去动态调整图标大小,颜色等等。
  • 但是因为是字体,所以不支持多色。只能使用平台里单色的图标,就算项目里有多色图标也会自动去色。

注意:新版 iconfont 支持多色图标,这些多色图标在 Unicode 模式下将不能使用,如果有需求建议使用symbol 的引用方式

Unicode 使用步骤如下:

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

@font-face {
  font-family: 'stbus';
  src: url('iconfont.eot');
  src: url('iconfont.eot?#iefix') format('embedded-opentype'),
      url('iconfont.woff2') format('woff2'),
      url('iconfont.woff') format('woff'),
      url('iconfont.ttf') format('truetype'),
      url('iconfont.svg#stbus') format('svg');
}

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

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

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

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

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

  • .stbus-icon-check
  • 步行
    .stbus-icon-walk
  • 刷新
    .stbus-icon-refresh3
  • 闹钟
    .stbus-icon-clock
  • 公交站牌
    .stbus-icon-location-site
  • 更多
    .stbus-icon-more
  • 微信好友
    .stbus-icon-weixin
  • .stbus-icon-cancel
  • 起点
    .stbus-icon-srart
  • 编辑
    .stbus-icon-edit
  • 新东方-刷新图标
    .stbus-icon-refresh
  • 删 除
    .stbus-icon-shanchu
  • 长箭头
    .stbus-icon-you
  • .stbus-icon-cha2
  • 更多
    .stbus-icon-more-up
  • 交通 公交车 看房团 大巴 面性
    .stbus-icon-bus
  • 一键
    .stbus-icon-one-do
  • .stbus-icon-cancel3
  • 刷新
    .stbus-icon-refresh2
  • 返回
    .stbus-icon-back2
  • 下 拉
    .stbus-icon-arrows-down
  • 长箭头
    .stbus-icon-arrows
  • 定位 位置
    .stbus-icon-location-point3
  • QQ
    .stbus-icon-qq
  • .stbus-icon-cancel2
  • 变更
    .stbus-icon-change2
  • 个人中心 我的 人物 标准头 面性
    .stbus-icon-user
  • 关于
    .stbus-icon-about
  • 回家
    .stbus-icon-go-home
  • 定位
    .stbus-icon-location-map
  • 终点
    .stbus-icon-end
  • 意见
    .stbus-icon-feedback
  • 换乘
    .stbus-icon-change3
  • 提醒
    .stbus-icon-notice2
  • 下 拉
    .stbus-icon-arrows-right
  • 收 藏
    .stbus-icon-collect
  • 菜单
    .stbus-icon-menu
  • 定位
    .stbus-icon-location
  • 首页-选中
    .stbus-icon-home
  • 历史
    .stbus-icon-history
  • 设 置
    .stbus-icon-config
  • 分 享
    .stbus-icon-share
  • 上班
    .stbus-icon-go-company
  • 上班
    .stbus-icon-go-work
  • 地图
    .stbus-icon-location-point2
  • 前进
    .stbus-icon-next
  • 定位 位置
    .stbus-icon-location-point
  • 加载
    .stbus-icon-loading
  • 地图
    .stbus-icon-map
  • 公告
    .stbus-icon-notice
  • 返回
    .stbus-icon-back
  • 公车管理
    .stbus-icon-car
  • 微博
    .stbus-icon-weibo
  • 变更
    .stbus-icon-change
  • 信息
    .stbus-icon-msg
  • 搜索
    .stbus-icon-search
  • 朋友圈
    .stbus-icon-pengyouquan
  • 警告
    .stbus-icon-warning
  • 更多
    .stbus-icon-more-right-copy
  • 更多
    .stbus-icon-more-down-copy

font-class 引用


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

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

  • 兼容性良好,支持 IE8+,及所有现代浏览器。
  • 相比于 Unicode 语意明确,书写更直观。可以很容易分辨这个 icon 是什么。
  • 因为使用 class 来定义图标,所以当要替换图标时,只需要修改 class 里面的 Unicode 引用。
  • 不过因为本质上还是使用的字体,所以多色图标还是不支持的。

使用步骤如下:

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

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

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

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

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

  • #stbus-icon-check
  • 步行
    #stbus-icon-walk
  • 刷新
    #stbus-icon-refresh3
  • 闹钟
    #stbus-icon-clock
  • 公交站牌
    #stbus-icon-location-site
  • 更多
    #stbus-icon-more
  • 微信好友
    #stbus-icon-weixin
  • #stbus-icon-cancel
  • 起点
    #stbus-icon-srart
  • 编辑
    #stbus-icon-edit
  • 新东方-刷新图标
    #stbus-icon-refresh
  • 删 除
    #stbus-icon-shanchu
  • 长箭头
    #stbus-icon-you
  • #stbus-icon-cha2
  • 更多
    #stbus-icon-more-up
  • 交通 公交车 看房团 大巴 面性
    #stbus-icon-bus
  • 一键
    #stbus-icon-one-do
  • #stbus-icon-cancel3
  • 刷新
    #stbus-icon-refresh2
  • 返回
    #stbus-icon-back2
  • 下 拉
    #stbus-icon-arrows-down
  • 长箭头
    #stbus-icon-arrows
  • 定位 位置
    #stbus-icon-location-point3
  • QQ
    #stbus-icon-qq
  • #stbus-icon-cancel2
  • 变更
    #stbus-icon-change2
  • 个人中心 我的 人物 标准头 面性
    #stbus-icon-user
  • 关于
    #stbus-icon-about
  • 回家
    #stbus-icon-go-home
  • 定位
    #stbus-icon-location-map
  • 终点
    #stbus-icon-end
  • 意见
    #stbus-icon-feedback
  • 换乘
    #stbus-icon-change3
  • 提醒
    #stbus-icon-notice2
  • 下 拉
    #stbus-icon-arrows-right
  • 收 藏
    #stbus-icon-collect
  • 菜单
    #stbus-icon-menu
  • 定位
    #stbus-icon-location
  • 首页-选中
    #stbus-icon-home
  • 历史
    #stbus-icon-history
  • 设 置
    #stbus-icon-config
  • 分 享
    #stbus-icon-share
  • 上班
    #stbus-icon-go-company
  • 上班
    #stbus-icon-go-work
  • 地图
    #stbus-icon-location-point2
  • 前进
    #stbus-icon-next
  • 定位 位置
    #stbus-icon-location-point
  • 加载
    #stbus-icon-loading
  • 地图
    #stbus-icon-map
  • 公告
    #stbus-icon-notice
  • 返回
    #stbus-icon-back
  • 公车管理
    #stbus-icon-car
  • 微博
    #stbus-icon-weibo
  • 变更
    #stbus-icon-change
  • 信息
    #stbus-icon-msg
  • 搜索
    #stbus-icon-search
  • 朋友圈
    #stbus-icon-pengyouquan
  • 警告
    #stbus-icon-warning
  • 更多
    #stbus-icon-more-right-copy
  • 更多
    #stbus-icon-more-down-copy

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>