如何用字体在网页中画icon
一。用css雪碧图
1.简介
(1)CSS Sprites能很好地减少网页的http请求,从而大大的提高页面的性能,这是CSS Sprites最大的优点,也是其被广泛传播和应用的主要原因;
二。用font-html
三。用font-css
一。css雪碧图是通过背景图片的定位方式在确定图标的位置,最终实现效果的
二。
用字体画icon需要借助一个网站:https://icomoon.io/app/#/select

//font+html实现,此方法可以兼容IE低版本。
.sprite{
margin: 10px auto;
width: 206px;
border: 1px solid #b51600;
}
.sprite li{
cursor: pointer;
height: 42px;
width: 206px;
background-color: #b51600;
border-bottom: 1px solid #911001;
border-top: 1px solid #c11e08;
}
.sprite li a {
color: #fff;
line-height: 42px;
font-size: 14px;
}
.sprite li s{
margin:0 10px;
}
.sprite li:hover{
background-color: #fff;
border-color: #fff
}
.sprite li:hover a{
color: #b51600;
}
@font-face{
font-family: "imooc-icon";
src: url("../fonts/icomoon.eot"); /* IE9 兼容模式 */
src: url("../fonts/icomoon.eot?#iefix") format("embedded-opentype")
,url("../fonts/icomoon.woff") format("woff")
,url("../fonts/icomoon.ttf") format("truetype")
,url("../fonts/icomoon.svg") format("svg");
font-weight: normal;
font-style: normal;
}
.imooc-icon{
font-family: "imooc-icon";
font-style: normal;
font-weight: normal;
font-size:20px;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="css/basic.css"/>
<link rel="stylesheet" type="text/css" href="css/fontHTML.css"/>
<title>字体图标icon</title>
</head>
<body>
<ul class="sprite">
<li>
<a href=""><s class="imooc-icon"></s>慕课网就是好1</a>
</li>
<li>
<a href=""><s class="imooc-icon"></s>慕课网就是好2</a>
</li>
<li>
<a href=""><s class="imooc-icon"></s>慕课网就是好3</a>
</li>
<li>
<a href=""><s class="imooc-icon"></s>慕课网就是好4</a>
</li>
<li>
<a href=""><s class="imooc-icon"></s>慕课网就是好5</a>
</li>
<li>
<a href=""><s class="imooc-icon"></s>慕课网就是好6</a>
</li>
<li>
<a href=""><s class="imooc-icon"></s>慕课网就是好7</a>
</li>
<li>
<a href=""><s class="imooc-icon"></s>慕课网就是好8</a>
</li>
<li>
<a href=""><s class="imooc-icon"></s>慕课网就是好9</a>
</li>
<li>
<a href=""><s class="imooc-icon"></s>慕课网就是好10</a>
</li>
<li>
<a href=""><s class="imooc-icon"></s>慕课网就是好11</a>
</li>
</ul>
</body>
</html>

//font+css画图标, 此方法不支持IE8以下版本
.sprite{
margin: 10px auto;
width: 206px;
border: 1px solid #b51600;
}
.sprite li{
cursor: pointer;
height: 42px;
width: 206px;
background-color: #b51600;
border-bottom: 1px solid #911001;
border-top: 1px solid #c11e08;
}
.sprite li a {
color: #fff;
line-height: 42px;
font-size: 14px;
}
.sprite li s{
margin:0 10px;
}
.sprite li:hover{
background-color: #fff;
border-color: #fff
}
.sprite li:hover a{
color: #b51600;
}
@font-face{
font-family: "imooc-icon";
src: url("../fonts/icomoon.eot"); /* IE9 兼容模式 */
src: url("../fonts/icomoon.eot?#iefix") format("embedded-opentype")
,url("../fonts/icomoon.woff") format("woff")
,url("../fonts/icomoon.ttf") format("truetype")
,url("../fonts/icomoon.svg") format("svg");
font-weight: normal;
font-style: normal;
}
.imooc-icon{
font-family: "imooc-icon";
font-style: normal;
font-weight: normal;
font-size:20px;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.icon-list:before{
content: "\e903"
}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="css/basic.css"/>
<link rel="stylesheet" type="text/css" href="css/fontCSS.css"/>
<title>font-css</title>
</head>
<!--IE8以下不兼容-->
<body>
<ul class="sprite">
<li>
<a href=""><s class="imooc-icon icon-list"></s>慕课网就是好1</a>
</li>
<li>
<a href=""><s class="imooc-icon icon-list""></s>慕课网就是好2</a>
</li>
<li>
<a href=""><s class="imooc-icon icon-list""></s>慕课网就是好3</a>
</li>
<li>
<a href=""><s class="imooc-icon icon-list""></s>慕课网就是好4</a>
</li>
<li>
<a href=""><s class="imooc-icon icon-list""></s>慕课网就是好5</a>
</li>
<li>
<a href=""><s class="imooc-icon icon-list""></s>慕课网就是好6</a>
</li>
<li>
<a href=""><s class="imooc-icon icon-list""></s>慕课网就是好7</a>
</li>
<li>
<a href=""><s class="imooc-icon icon-list""></s>慕课网就是好8</a>
</li>
<li>
<a href=""><s class="imooc-icon icon-list""></s>慕课网就是好9</a>
</li>
<li>
<a href=""><s class="imooc-icon icon-list""></s>慕课网就是好10</a>
</li>
<li>
<a href=""><s class="imooc-icon icon-list""></s>慕课网就是好11</a>
</li>
</ul>
</body>
</html>

实在不知道如何解释,提醒各位可以上慕课网:http://www.imooc.com/video/5431上面听一下,会受益匪浅。
如何用字体在网页中画icon的更多相关文章
- 用字体在网页中画Icon图标
第一步,下载.IcoMoon网站选择字体图标并下载,解压后将fonts文件夹放在工程目录下.fonts文件夹内有四种格式的字体文件: 注:由于浏览器对每种字体的支持程度不一致,要想在所有浏览器中都显示 ...
- 字体在网页中画ICON图标
用字体在网页中画ICON图标有三种小技巧: 1.用CSS Sprite在网页中画小图标 实现方法: 首先将小图片整合到一张大的图片上 然后根据具体图标在大图上的位置,给背景定位.background- ...
- 用字体在网页中画icon小图标
HTML结构: <i class="icons icon-ui"> 㐺 <i> <i class="icons icon-ui"& ...
- 在网页中制作icon图标
用字体在网页中画icon图标 第一步:获取字体资源IconMoon网站https://icomoon.io iconMoon中有很多免费小图标可用,还能设置下载图标的使用属性(通过网站中设立的按钮pr ...
- 用Raphael在网页中画圆环进度条
原文 :http://boytnt.blog.51cto.com/966121/1074215 条状的进度条我们见得太多了,实现起来比较简单,它总是长方形的,在方形的区域里摆 放就不太好看了.随着cs ...
- 如何用iframe在网页中插入另一个网页的一部分内容,做成页中页
<html><head></head><body><h1>这是一段引用的内容!!!</h1><div style=&quo ...
- 如何用JS判断网页中某个id的网页元素是否存在
<meta http-equiv="content-type" content="text/html;charset=utf-8" /> <m ...
- 网页中导入特殊字体@font-face属性详解
@font-face是CSS3中的一个模块,他主要是把自己定义的Web字体嵌入到你的网页中. 语法规则 首先我们一起来看看@font-face的语法规则: @font-face { font-fami ...
- 利用CSS的@font-face属性 在网页中嵌入字体
字体使用是网页设计中不可或缺的一部分.网页是文字的载体,我们希望在网页中使用某一特定字体,但是该字体并非主流操作系统的内置字体,这样用户在浏览页面的时候就有可能看不到真实的设计. 美工设计师最常做的办 ...
随机推荐
- jquery 一键复制到剪切板
今天做项目有一个功能,通过点击事件复制一段文本到剪切板,在网上找了一些,整理了一下,方便需要的朋友使用. <a id="copy" data-text="12345 ...
- MySQL查询优化方法总结
1.应尽量避免在 where 子句中使用!=或<>操作符,否则将引擎放弃使用索引而进行全表扫描. 2.对查询进行优化,应尽量避免全表扫描,首先应考虑在 where 及 order by 涉 ...
- 数组Array和字符串String的indexOf方法,以及ES7(ES2016)中新增的Array.prototype.includes方法
前言 我们在判断某一个字符是否存在于一个字符串中或者某一个值是否存在于一个数组中时,ES7之前我们需要使用indexOf,ES7引入了新的方法includes 语法 数组:Array.inexOf(s ...
- 【TensorFlow入门完全指南】模型篇·最近邻模型
最近邻模型,更为常见的是k-最近邻模型,是一种常见的机器学习模型,原理如下: KNN算法的前提是存在一个样本的数据集,每一个样本都有自己的标签,表明自己的类型.现在有一个新的未知的数据,需要判断它的类 ...
- lastlog命令
lastlog——检查某特定用户上次登录的时间 命令所在路径:/usr/bin/lastlog 示例1: # lastlog 列出所有用户,并显示用户最后一次登录的时间等信息 示例2: # lastl ...
- Windows服务管理
按键:win+R 输入:services.msc “服务和应用程序”界面选项打开 * sc命令的使用:create(创建) delete(删除)等 * service可执行文件路径的修改:win+R ...
- VPS Linux SSH 客户端断开后保持进程继续运行配置方法——screen
前言 在Linux中,我们经常会做一些关于数据的操作(备份.传输.压缩等)或是要在后台持续的运行一些程序.由于,工作的数据量很大或者工作要持续很长的时间,我们就必须保证这个终端的启动,一旦终端关闭了, ...
- linux简单常用命令
除了yum命令,还有些简单的命令,在此记录一下,加深记忆: free -h 查询内存和交换分区. rpm -qa | grep libaio 查看当前环境是否安装某rpm软件包
- JDBC操作数据库的详细步骤
1.注册驱动 告知JVM使用的是哪一个数据库的驱动 2.创建连接 使用JDBC中的类,完成对MySQL数据库的连接 3. 得到执行sql语句的Statement对象 通过连接对象获取对SQL语句的执行 ...
- 【Python学习之七】面向对象高级编程——__slots__的使用
1.Python中的属性和方法的绑定 正常情况下,当我们定义了一个class,创建了一个class的实例后,我们可以给该实例绑定任何属性和方法. (1)首先,定义一个class: class Stu ...