码迷,mamicode.com
首页 > 其他好文 > 详细

文字图标

时间:2018-12-28 20:41:49      阅读:703      评论:0      收藏:0      [点我收藏+]

标签:oci   cad   wak   mha   border   需要   rrg   type   lang   

一.代码示例

 1 <!DOCTYPE html>
 2 <html lang="en">
 3 <head>
 4     <meta charset="UTF-8">
 5     <title>文字图标</title>
 6     <style type="text/css">
 7        @font-face {font-family: "iconfont";
 8   src: url(‘download/1/iconfont.eot?t=1545985335074‘); /* IE9*/
 9   src: url(‘download/1/iconfont.eot?t=1545985335074#iefix‘) format(‘embedded-opentype‘), /* IE6-IE8 */
10   url(‘download/1/data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAAAaQAAsAAAAACXQAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAADMAAABCsP6z7U9TLzIAAAE8AAAARAAAAFY9CkiGY21hcAAAAYAAAABLAAABcOe8t2ZnbHlmAAABzAAAAt4AAAOAPhChUmhlYWQAAASsAAAALwAAADYTt0BXaGhlYQAABNwAAAAcAAAAJAfeA4NobXR4AAAE+AAAAAgAAAAICAAAAGxvY2EAAAUAAAAABgAAAAYBwAAAbWF4cAAABQgAAAAfAAAAIAEfAS1uYW1lAAAFKAAAAUUAAAJtPlT+fXBvc3QAAAZwAAAAHQAAAC5phm1veJxjYGRgYOBikGPQYWB0cfMJYeBgYGGAAJAMY05meiJQDMoDyrGAaQ4gZoOIAgCKIwNPAHicY2BkYWCcwMDKwMHUyXSGgYGhH0IzvmYwYuRgYGBiYGVmwAoC0lxTGByeTXk2hbnhfwNDDHMDQwNQmBEkBwD0RQ0LeJxjYGBgZWBgYAZiHSBmYWBgDGFgZAABP6AoI1icmYELLM7CoARWwwISfzbl/38YCeSzgEkGRjaGUcADJmWgPHBYQTADIwCS4Qu5AHicXVBNbBNHGJ03uzs76+7OJvF61jHxbux1vAlV4vinuyk2jlB7cLgBF+ACgoBAoocipAoQOE05QKVKEYdI5YAqpadyAE6AhESFVC6tBMfmUA6cuHCBcA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TpsqiSPHrdQDcB6OwAk4AtyAO/BIJ5s2lsffvHljTwDc4Acejt8t95E9XDI7cg0XuBeuU38QbpBfhJto41W4Rf1N2MczpsJtdGF5g9e4YvaEd2EPHXwI13CNT+E69S/hBvlbuIk7/Aq30PHqwj7mXle4jUcv9sdWL5xeqeVBxaHJIpM5v4KZXu+Sha3S6pxrW8QmU4OgX0lTnWlb3VPs10PnIhVZk6oJqzpJjMqt2erQBRvn8lGvF4kehCblWGP+tsYCjnEFhSUOjDFCGGSIyujoO1Vm9K+xQ8Jee1Y9zed0WxTU/3OFAQL0z1xTurLSeTpPgT1fG1J1dCtuy56UNJFezUkSskJe1rZUQuoBNmVXjhF6XNGJPyhnSP8ACVpuyAAAAHicY2BigAAuBuyAiZGJkZmBJaM0J5OBAQAKGwHMAAAA‘) format(‘woff‘),
11   url(‘download/1/iconfont.ttf?t=1545985335074‘) format(‘truetype‘), /* chrome, firefox, opera, Safari, Android, iOS 4.2+*/
12   url(‘download/1/iconfont.svg?t=1545985335074#iconfont‘) format(‘svg‘); /* iOS 4.1- */
13 }
14 
15 .iconfont {
16   font-family:"iconfont";
17   font-size:16px;
18   font-style:normal;
19   font-size: 80px;
20   /*width: 300px;
21   height: 300px;
22   border: 1px solid red;
23   text-align: center;
24   line-height: 300px;
25   color: purple;*/
26   /*这就是文字图片的魅力,可以在控制台修改图片文字的样式*/
27 }
28 
29 .iconfont:before { content: "\e694"; }
30     </style>
31 </head>
32 <body>
33     <!-- 
34         www.iconfont.cn
35      -->
36      <div class="iconfont">
37      </div>
38 </body>
39 </html>

技术分享图片  

 

 中间那行图片文字的属性代码解除注释

技术分享图片


二.演示一下使用

首先进入

www.iconfont.cn阿里的图标网站

技术分享图片

 

这里作为演示:我选取了一个青蛙图标,点击添加入库

技术分享图片

点击右上角,在库里点击下载代码,得到zip压缩文件,并且解压

技术分享图片  

技术分享图片

 

 解压文件中的文件目录如下(download有个文件目录名字很长被我修改成2,方便寻找路径):

技术分享图片

 

将文件拖拽至sublime中,相应结构如下(可对比一下上图即可看懂):

 技术分享图片

点击iconfont.css(需要做些修改):

技术分享图片

修改后:

技术分享图片

在编辑html文件中本例用的是link样式表,把iconfont.css的路径引入href链接中,并且填入class选择器(这就是为什么要把before前的class名修改的原因):

 1 <!DOCTYPE html>
 2 <html lang="en">
 3 <head>
 4     <meta charset="UTF-8">
 5     <title>快乐的一只小青蛙</title>
 6     <link rel="stylesheet" type="text/css" href="D:\编程视频笔记\HTML与css笔记\css3进阶\服务器字体及弹性盒模型\文字图标示例\download\2\iconfont.css">
 7 </head>
 8 <body>
 9     <div class="iconfont"></div>
10 </body>
11 </html>

 看看效果:

技术分享图片

 

是不是很小,那么让我们再次进入iconfont.css外部css表中添加一些样式:

 

 1 @font-face {font-family: "iconfont";
 2   src: url(‘iconfont.eot?t=1545996225217‘); /* IE9*/
 3   src: url(‘iconfont.eot?t=1545996225217#iefix‘) format(‘embedded-opentype‘), /* IE6-IE8 */
 4   url(‘data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAAAWwAAsAAAAACQgAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAADMAAABCsP6z7U9TLzIAAAE8AAAARAAAAFY9BUiBY21hcAAAAYAAAABLAAABcOe3t1dnbHlmAAABzAAAAgIAAAMYRIUEPWhlYWQAAAPQAAAALwAAADYTt5WCaGhlYQAABAAAAAAcAAAAJAfeA4NobXR4AAAEHAAAAAgAAAAICAAAAGxvY2EAAAQkAAAABgAAAAYBjAAAbWF4cAAABCwAAAAgAAAAIAEkAP5uYW1lAAAETAAAAUUAAAJtPlT+fXBvc3QAAAWUAAAAGwAAACx4cgEEeJxjYGRgYOBikGPQYWB0cfMJYeBgYGGAAJAMY05meiJQDMoDyrGAaQ4gZoOIAgCKIwNPAHicY2BkYWCcwMDKwMHUyXSGgYGhH0IzvmYwYuRgYGBiYGVmwAoC0lxTGBye9T/rZ27438AQw9zA0AAUZgTJAQDzfQ0BeJxjYGBgZWBgYAZiHSB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cI1P4Tr1L+EG+Vu4iTv8CrfQ8erCPuZeV7iNRy/2x1YvnF6p5UHFockikzm/gple75KFrdLqnGtbxCZTg6BfSVOdaVvdU+zXQ+ciFVmTqgmrOkmMyq3Z6tAFG+fyUa8XiR6EJuVYY/62xgKOcQWFJQ6MMUIYZIjK6Og7VWb0r7FDwl57Vj3N53RbFNT/c4UBAvTPXFO6stJ5Ok+BPV8bUnV0K27LnpQ0kV7NSRKyQl7WtlRC6gE2ZVeOEXpc0Yk/KGdI/wAJWm7IAAAAeJxjYGKAAC4G7ICJkYmRmYGpPJGBAQAFOADwAA==‘) format(‘woff‘),
 5   url(‘iconfont.ttf?t=1545996225217‘) format(‘truetype‘), /* chrome, firefox, opera, Safari, Android, iOS 4.2+*/
 6   url(‘iconfont.svg?t=1545996225217#iconfont‘) format(‘svg‘); /* iOS 4.1- */
 7 }
 8 
 9 .iconfont {
10   font-family:"iconfont";
11   font-size:80px;
12   font-style:normal;
13   width:300px;
14   height: 300px;
15   text-align: center;
16   line-height: 300px;
17   color: purple;
/*上面是修改区域,增大了字体,改变了颜色等*/
18 } 19 20 .iconfont:before { content: "\e68f"; }

效果:

技术分享图片

so,而在相应的浏览器上可以通过控制台修改,这:就是图片文字的魅力!!

喜欢的小可爱们双击哦!

文字图标

标签:oci   cad   wak   mha   border   需要   rrg   type   lang   

原文地址:https://www.cnblogs.com/zjm1999/p/10192528.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!