CSS Sprites (CSS Wizard)

Source: Internet
Author: User

A. What is CSS Sprites?

General CSS Wizard, is a Web page image application processing method. It allows you to include all the scattered images of a page in a large image, so that when you visit the page, the loaded picture will not be shown as a picture of the past. Then use the CSS "Background-image", "Background-repeat", "background-position" the combination of background positioning.

Two. Pros and cons of using CSS Sprites

Advantages:

1. Greatly improve the performance of the page by reducing the HTTP request of the Web page very well.

2. Reduce the number of bytes in the picture, the bytes of multiple images merged into 1 pictures are always smaller than the sum of the bytes of multiple pictures.

3. Solve the problem of image naming.

Disadvantages:

1. When the picture is merged, it is necessary to combine multiple pictures into one picture in order, and to keep enough space to prevent unnecessary background in the plate;

2. In widescreen, high-resolution screen under the adaptive page, if the picture is not wide enough, it is easy to appear background break;

3..CSS Sprites When developing, it is recommended to use CSS Sprites style generation tools to measure the exact location of each background unit.

4.CSS sprites in maintenance, if the page background has a little change, it is generally necessary to change the merged picture.

Summary: The general CSS sprites flattening layout is used for local small box layouts that are not suitable for large background large layout backgrounds. such as small local layout small icon background, small navigation background, such as CSS layout. In short, many times we have to weigh the pros and cons, and then decide whether to apply CSS Sprites.

Three. Give me a chestnut.

A picture of a emoji

Final effect:

HTML code:

    <ul>        <li class= "Emoji1" ></li>        <li class= "Emoji2" ></li>        <li class= " Emoji3 "></li>        <li class=" Emoji4 "></li>    </ul>

CSS code:

*{        margin:0px;    }    ul,li{        list-style:none;    }    li{        width:50px;        height:50px;        Overflow:hidden;        Background:url (' emoji.jpg ') -0px-0px no-repeat;    }     . emoji1{        background-position: -0px-0px;    }    . emoji2{        background-position: -0px-50px;    }    . emoji3{        background-position: -0px-100px;    }    . emoji4{        background-position: -0px-150px;    }

  

CSS Sprites (CSS Wizard)

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.