如何用字体在网页中画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属性 在网页中嵌入字体
字体使用是网页设计中不可或缺的一部分.网页是文字的载体,我们希望在网页中使用某一特定字体,但是该字体并非主流操作系统的内置字体,这样用户在浏览页面的时候就有可能看不到真实的设计. 美工设计师最常做的办 ...
随机推荐
- [20190611]记录一下github的基本用法
本文记录如何使用github创建项目并上传代码,因为有一段时间没用github了,中途又重装了系统,今天重新使用一下. 然后特地做简要记录: 1. 创建SSH Key SSH Key指一般在C:\Us ...
- 关于火狐浏览器在ubuntu和安卓手机上的同步
最近在ubuntu使用火狐浏览器,感觉还不错.我想着,如果在我的安卓手机上装一个火狐浏览器,我就可以在手机上查看电脑上所收藏的网站了.然后我就去安卓应用市场下载了最新版的火狐浏览器.令人奇怪的是,我在 ...
- NGUI类之间的关系架构
NGUI Drawcall 1.使用同一个altals的元素尽量放在同一个UIPanel下面,在NGUI中,它消耗的drawcall是以每个Panel为独立计算单位进行计算的. 2.如果一个UIPan ...
- UVA 140 Brandwidth 带宽 (dfs回溯)
看到next_permutation好像也能过╮(╯▽╰)╭ 这题学习点: 1.建图做映射 2.通过定序枚举保证字典序最小 3.strtok,sscanf,strchr等函数又复习了一遍,尽管程序中没 ...
- C++11 function用法 可调用对象模板类
std::function<datatype()> ()内写参数类型 datatype 代表function的返回值 灵活的用法.. 代码如下 #include <stdio.h&g ...
- JDK的安装以及环境变量的配置
一.JDK的安装 1.百度搜索jdk1.8 2.进入网页选择Downloads 3. 选择电脑的版本(x86 32位 x64 64位) 4.下载好后,直接双击即可,一直下一步即可完成安装 二.环境变量 ...
- thinkphp的使用——隐藏index.php
官方默认的.htaccess文件 <IfModule mod_rewrite.c> Options +FollowSymlinks -Multiviews RewriteEngine ...
- linux - mysql 安装教程
环境介绍>>>>>>>>>>>>>>>>>> 操作系统:Centos 7 mysql数据库版 ...
- 瀑布流封装(仿写UITableView)
本篇文章将会仿照苹果系统提供的UITableView类,封装一个瀑布流效果的控件!!! 该控件和系统的UITableView是相同级别的 (继承自系统的UIScrollView) GitHub中Dem ...
- iOS监听电话来电、挂断、拨号等
以下,来讲解在app内如何调用打电话功能和监听电话来电.挂断.拨号等功能. 简单的UI布局: 首先,先实现拨打电话的功能,以便于后续测试: // 拨打电话 - (IBAction)dialingBut ...