search
HomeWeb Front-endHTML TutorialAwesome图标和css特殊字体的使用方法_html/css_WEB-ITnose

 

作为第一篇博文,写这个 我快要被气炸,好吧,废话不说了

昨天在项目中发现有很多这些Awesome图标 也在网上找了下Font Awesome 下载后这些文件,

 

 现在的版本是4.2,Font Awesome从4.1.0版本开始不再支持IE7, 但更早的版本仍然支持,如果需要考虑IE7有下面解决方法

一,首先将css文件下的文件复制到我们项目css文件夹中,在

中引入奥森图标的css样式 这个毋庸置疑,至于引入压缩版还是不压缩版 看心情

 

 

我这里下的有个ie7的压缩版,有些地方下的没有这个文件,这个是考虑到还在坚持使用ie7的古董们而出现的,直接引入即可

同样也可以用CDN引入,官网有介绍。

 

二,使用图标这个不需要太多介绍,对应着奥森图标网站寻找class,如 前面的fa是必须的 后面的class是对应图标的class

三,查看下项目 蛋疼的是图标呢, 哪去了。。。。查看下控制台

 

 

一堆报错,显示没有找到fonts这个文件夹下的字体, 我会说 我没有引入fonts里面的东西啊 为什么会出现这个报错,其实我也不知道

应该是引入Awesome的css文件项目会自动寻找fonts这个文件夹,现在把fonts文件夹引入到项目(直接把文件夹复制到项目 别改了文件夹名字 昨天就是fonts改成font 我擦 搞得气死了 这么easy的事情竟然找了许久)

OK。。图标成功出现了,蛋疼的问题就是 一定要把对应字体的文件夹引入好

 

CSS特殊字体使用方法

好的 上面这个图标问题解决了,再来看下网页中引入特殊字体时使用方法吧,

特殊字体的引入靠@font-face语句实现 这些字体浏览器的支持还是良好的,低至IE6/IE4都支持,很不错,兼容问题就不要考虑了

主要格式四种(.eot、.woff、.svg、.ttf),为什么会有四个 是针对不同浏览器各自为政出现的,不说太详细 都引入就对了,引入各式

1,YourWebFontName:下载的字体名称;

2,source:此值指的是你自定义的字体的存放路径,可以是相对路径也可以是绝路径;

3,format:此值指的是你自定义的字体的格式,也就是上面说的四种格式 帮助各种浏览器识别

4,weight和style:即字体的粗细和样式。

 

OK。。。 举个例子,下载个raphaelicons字体,下载后一个fonts文件夹

两个txt文本不考虑,有四个字体,现在在css样式中引入四种字体

1 @font-face{2     font-family: 'Raphaelicons';3     src:url('fonts/raphaelicons-webfont.eot')format('eot');4     src:url('fonts/raphaelicons-webfont.svg')format('svg');5     src:url('fonts/raphaelicons-webfont.woff')format('woff');6     src:url('fonts/raphaelicons-webfont.ttf')format('truetype');7     font-weight: normal;8     font-style: normal;9 }

 

 该庆祝下。。 已经把字体成功引入样式,看下结构

1 <div class="st-desc" data-icon="H"></div>

 

注:特殊字体使用需要使用 data-icon="" 来定义图标,相对应的H就会变成所下字体的图标,定义css样式

1 [data-icon]:after{2     content: attr(data-icon);3     width: 200px;4     height: 200px;5     color: #fff;6     font-size: 90px;7     font-family: 'Raphaelicons';8     text-shadow:1px 1px 1px rgba(151,24,64,0.2);9 }

 

很关键的一步在样式中使用字体 font-family:"Raphaelicons"; 如果没有将引入的字体使用 那图标的样式是不会出现

好看的图标出现了 定义的H变成了 美妙吧。。

其他特殊字体的引入也是如此,先@font-face引入字体  data-icon定义字体  定义data-icon样式  使用字体 欧卡。。。

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
The Future of HTML, CSS, and JavaScript: Web Development TrendsThe Future of HTML, CSS, and JavaScript: Web Development TrendsApr 19, 2025 am 12:02 AM

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

HTML: The Structure, CSS: The Style, JavaScript: The BehaviorHTML: The Structure, CSS: The Style, JavaScript: The BehaviorApr 18, 2025 am 12:09 AM

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The Future of HTML: Evolution and Trends in Web DesignThe Future of HTML: Evolution and Trends in Web DesignApr 17, 2025 am 12:12 AM

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

HTML vs. CSS vs. JavaScript: A Comparative OverviewHTML vs. CSS vs. JavaScript: A Comparative OverviewApr 16, 2025 am 12:04 AM

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.

HTML: Is It a Programming Language or Something Else?HTML: Is It a Programming Language or Something Else?Apr 15, 2025 am 12:13 AM

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

HTML: Building the Structure of Web PagesHTML: Building the Structure of Web PagesApr 14, 2025 am 12:14 AM

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.

From Text to Websites: The Power of HTMLFrom Text to Websites: The Power of HTMLApr 13, 2025 am 12:07 AM

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.

Understanding HTML, CSS, and JavaScript: A Beginner's GuideUnderstanding HTML, CSS, and JavaScript: A Beginner's GuideApr 12, 2025 am 12:02 AM

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

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.