立即注册 登录
召隆企博汇论坛 返回首页

linmy的个人空间 http://bbs.clogcn.com/?9 [收藏] [复制] [分享] [RSS]

日志

前端知识 字体图标

已有 583 次阅读2019-12-15 13:57

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

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

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

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

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

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

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

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

iconfont.css内容如下:


<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>postMessage解决跨域、跨窗口消息传递</title>

<style type="text/css">

@font-face {font-family: "iconfont";

  src: url('fonts/iconfont.eot?t=1483950473775'); /* IE9*/

  src: url('fonts/iconfont.eot?t=1483950473775#iefix') format('embedded-opentype'), /* IE6-IE8 */

  url('fonts/iconfont.woff?t=1483950473775') format('woff'), /* chrome, firefox */

  url('fonts/iconfont.ttf?t=1483950473775') format('truetype'), /* chrome, firefox, opera, Safari, Android, iOS 4.2+*/

  url('fonts/iconfont.svg?t=1483950473775#iconfont') format('svg'); /* iOS 4.1- */

}

.iconfont {

  font-family:"iconfont" !important;

  font-size:16px;

  font-style:normal;

  color: lightblue;

  -webkit-font-smoothing: antialiased;

  -moz-osx-font-smoothing: grayscale;

}

.icon-xingzuotianchengzuo:before { content: "\e672"; }

@font-face {font-family: "iconfont";

  src: url('fonts/iconfont.eot?t=1483951178754'); /* IE9*/

  src: url('fonts/iconfont.eot?t=1483951178754#iefix') format('embedded-opentype'), /* IE6-IE8 */

  url('fonts/iconfont2.woff?t=1483951178754') format('woff'), /* chrome, firefox */

  url('fonts/iconfont2.ttf?t=1483951178754') format('truetype'), /* chrome, firefox, opera, Safari, Android, iOS 4.2+*/

  url('fonts/iconfont.svg?t=1483951178754#iconfont') format('svg'); /* iOS 4.1- */

}

.icon-star:before { content: "\e602"; }

</style>

</head>

<body>

<div style="width: 200px; float: left;margin-right: 200px;border: 1px solid #3F3F3F;">

<i class="iconfont icon-xingzuotianchengzuo"></i>

<i class="iconfont icon-star"></i>

</body>

</html>


路过

雷人

握手

鲜花

鸡蛋

评论 (0 个评论)

facelist

您需要登录后才可以评论 登录 | 立即注册

QQ|Archiver|手机版|小黑屋|召隆企博汇 ( 粤ICP备14061395号 )

GMT+8, 2026-6-27 06:25 , Processed in 0.021662 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部