1、什么是iconfont?
说白了就是用图标制作而成的一套字体文件,本质是一个字体文件(扩展名是ttf\woff\svg的文件)。它是用来制作网页常用小图标的一种方法。以下是天猫首页使用iconfont的场景:
2、用iconfont有什么优缺点?
1)文件小,以往常用的sprite图如果要放上上百个图标,那么这张图的大小可能有100k+,而上百个图标做成的iconfont文件,往往只有十几k
2)可缩放,因为是矢量的字体文件,因此不像sprite图放大到一定尺寸了图片失真严重
3)缺点:只能使用单色,毕竟只是个字体嘛
3、如何制作iconfont字体文件?
首先你需要安装2个工具,一个是Adobe的illustrator,一个是FontLab studio(点击下载)。
illustrator是用来打开设计师给你的eps矢量文件的,而FontLab则是字体制作工具。下面来看一下使用方法:
1)复制图形。打开illustrator,把设计师做好的图标的eps文件打开,点击选择工具,在画布中选择整个矢量图形,按下ctrl+C复制图形,如图:
2)创建字体文件。打开FontLab,选择 文件>新建,打开一个新字体编辑文件,双击任意一个字符打开该字符的编辑器,如图:
3)粘贴图标。然后将你在illustrator中复制出来的图标,按ctrl+V粘贴到FontLab中的字符编辑器中,并用左侧的工具栏移动或者调整缩放(快捷键ctrl+9)至合适的位置
4)导出字体。点击 文件>生成字体,将编辑好的字体文件导出成字体,一般选择ttf格式保存。(如果你的FontLab未注册,那么会提示你无法保存,破解的方法请自行百度,此文不赘述)
字体文件生成并保存后,就生成了如下图这样的字体文件,它的大小只有3k左右(你还可以继续添加图标,但k数不会增长太大)
4、如何在代码中使用iconfont?
1)引入CSS。首先我们要先把这个字体文件引入css,由于不同浏览器对字体文件支持不同,因此需要将ttf格式转成不同格式的字体文件来兼容。字体文件转格式网上有许多线上转换的工具,我常用的是这个:http://www.freefontconverter.com/
引入代码如下(不同格式的文件使用的语法不同,这点我也还没搞太清楚,先参照前辈的写):
@font-face { font-family: 'star'; src: url('star.eot'); /* 兼容IE9*/ src: url('star.eot?#iefix') format('embedded-opentype'), /* 兼容IE6-IE8 */ url('star.woff') format('woff'), /* 兼容chrome、firefox */ url('star.ttf') format('truetype'), /* 兼容chrome、firefox、opera、Safari, Android, iOS 4.2+*/ url('star.svg#uxiconfont') format('svg'); /* 兼容iOS 4.1- */ }
2)使用iconfont。在需要使用图标的地方,通过伪元素来运用iconfont,例如:
.something::before{ font-family:"star";/*上面引入字体文件的命名*/ content:"A";/*我们的图标在字体文件中占了A的位置*/ font-size:14px; color:#000 }

The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

The role of HTML is to define the structure and content of a web page through tags and attributes. 1. HTML organizes content through tags such as , making it easy to read and understand. 2. Use semantic tags such as, etc. to enhance accessibility and SEO. 3. Optimizing HTML code can improve web page loading speed and user experience.

HTMLisaspecifictypeofcodefocusedonstructuringwebcontent,while"code"broadlyincludeslanguageslikeJavaScriptandPythonforfunctionality.1)HTMLdefineswebpagestructureusingtags.2)"Code"encompassesawiderrangeoflanguagesforlogicandinteract

HTML, CSS and JavaScript are the three pillars of web development. 1. HTML defines the web page structure and uses tags such as, etc. 2. CSS controls the web page style, using selectors and attributes such as color, font-size, etc. 3. JavaScript realizes dynamic effects and interaction, through event monitoring and DOM operations.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version
Visual web development tools

Notepad++7.3.1
Easy-to-use and free code editor