使用阿里巴巴图标库生成iconfont字体图标

文章标签: 阿里云图标

iconfont字体图标就是用字体来代替图标、图片文件的做法,并且通过字体图标可以对图标的大小、颜色等进行控制,但是缺点就是只能实现一种颜色,不能像图片那样含有各种颜色。

通过阿里巴巴图标库制作字体图标步奏如下(默认已注册阿里巴巴图标库):

1、首先搜索所要展示的图片,找到后点击入库。


2、点击入库的图标,结果如下图所示,选择添加至项目或点新建项目。


3、点击确定之后如下图所示,鼠标悬浮在上面可以选择对图标信息进行修改。


4、选择Font class,点击下载至本地便把字体编辑好了。


5、结下来是使用字体,选中生成的字体添加至项目工程中。


6.修改css文件引用生成的字体


iconfont.css内容如下:

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>postMessage解决跨域、跨窗口消息传递</title>
  6. <style type="text/css">
  7. @font-face {font-family: "iconfont";
  8. src: url('fonts/iconfont.eot?t=1483950473775'); /* IE9*/
  9. src: url('fonts/iconfont.eot?t=1483950473775#iefix') format('embedded-opentype'), /* IE6-IE8 */
  10. url('fonts/iconfont.woff?t=1483950473775') format('woff'), /* chrome, firefox */
  11. url('fonts/iconfont.ttf?t=1483950473775') format('truetype'), /* chrome, firefox, opera, Safari, Android, iOS 4.2+*/
  12. url('fonts/iconfont.svg?t=1483950473775#iconfont') format('svg'); /* iOS 4.1- */
  13. }
  14. .iconfont {
  15. font-family:"iconfont" !important;
  16. font-size:16px;
  17. font-style:normal;
  18. color: lightblue;
  19. -webkit-font-smoothing: antialiased;
  20. -moz-osx-font-smoothing: grayscale;
  21. }
  22. .icon-xingzuotianchengzuo:before { content: "\e672"; }
  23. @font-face {font-family: "iconfont";
  24. src: url('fonts/iconfont.eot?t=1483951178754'); /* IE9*/
  25. src: url('fonts/iconfont.eot?t=1483951178754#iefix') format('embedded-opentype'), /* IE6-IE8 */
  26. url('fonts/iconfont2.woff?t=1483951178754') format('woff'), /* chrome, firefox */
  27. url('fonts/iconfont2.ttf?t=1483951178754') format('truetype'), /* chrome, firefox, opera, Safari, Android, iOS 4.2+*/
  28. url('fonts/iconfont.svg?t=1483951178754#iconfont') format('svg'); /* iOS 4.1- */
  29. }
  30. .icon-star:before { content: "\e602"; }
  31. </style>
  32. </head>
  33. <body>
  34. <div style="width: 200px; float: left;margin-right: 200px;border: 1px solid #3F3F3F;">
  35. <i class="iconfont icon-xingzuotianchengzuo"></i>
  36. <i class="iconfont icon-star"></i>
  37. </div>
  38. </body>
  39. </html>

还能输出{{restrictNumber}}个字符  
  • {{reply.author}}

    {{CommonUtil.formateDate(reply.ac_CommentDate).shortTime}}
  • 回复了{{Comments.author}} :