Use icon fonts to help CSS process pictures

Source: Internet
Author: User

Because the mobile device has different resolution, PPI and other problems caused by the need for different screen resolution to adjust the optimization, such as the use of @2x pictures, max-width restrictions.

Using CSS @font-face is also a good way to display icon.

Because the icon fonts (font) is a vector graphic, it is not affected by the resolution, but also to achieve the perfect zoom, of course, can also be used on the WEB side.

Advantages

File Small

Good loading performance

CSS style support

The IE6/7 also supports

Disadvantages

Style restrictions, using flat style

There are incompatibilities on the mobile end

A small number of mobile devices and icon fonts character encoding conflicts

Cross-domain problems under FF and IE9

Performance issues

How to use

Making font Files

Can be manually made using the Font tool

You can also use online tools to automatically generate

Referenced in CSS, as follows

Introducing Font Files

CSS code copy content to clipboard

@font-face {font-family: ' Iconfont ';

Src:url (' Iconfont.eot '); /* ie9*/

Src:url (' Iconfont.eot #iefix ') format (' Embedded-opentype '),/* IE6-IE8 *

URL (' iconfont.woff ') format (' Woff '),/* Chrome, Firefox * *

URL (' Iconfont.ttf ') format (' TrueType '), * * Chrome, Firefox, Opera, Safari, Android, IOS 4.2+*/

URL (' iconfont.svg#uxiconfont ') format (' SVG '); /* IOS 4.1-* *

}

Then define a icon-* with all of our icons in a common CSS style,

CSS code copy content to clipboard

[class^= "icon-"], [class*= "icon-"] {

Display:inline-block;

Speak:none

font-family: "Iconfont";

font-size:16px;

Line-height:1;

Font-style:normal;

/** font icon appears jagged problem: * *

-webkit-font-smoothing:antialiased;

-moz-osx-font-smoothing:grayscale;

}

The last is to use: before to inject each icon corresponding to the font encoding

CSS code copy content to clipboard

. icon-bell:before {

Content: "03432";

}

. icon-search:before {

Content: "03433";

}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.