CSS Sprites(CSS sprite)

WBOY
Release: 2016-09-11 11:19:48
Original
1560 people have browsed it

1. What are CSS Sprites?

 General css sprite is a web image application processing method. It allows you to include all the scattered pictures involved in a page into one big picture, so that when the page is accessed, the loaded pictures will not be displayed one by one as before. . Then use the combination of CSS "background-image", "background-repeat" and "background-position" to position the background.

2. Advantages and disadvantages of using CSS Sprites

Advantages:

1. Reduce the http requests of web pages, thereby greatly improving the performance of the page.

2. Reduce the bytes of pictures. The bytes of merging multiple pictures into one picture are always less than the sum of bytes of multiple pictures.

3. Solve the problem of naming pictures.

Disadvantages:

1. When merging pictures, multiple pictures should be merged into one picture in an orderly and reasonable manner, and enough space should be left to prevent unnecessary backgrounds from appearing in the section;

2. On adaptive pages under widescreen and high-resolution screens, if the picture is not wide enough, it is easy for the background to break;

3.. When developing CSS Sprites, it is necessary to measure and calculate the precise position of each background unit. It is recommended to use the CSS Sprites style generation tool.

4. During CSS Sprites maintenance, if the page background is slightly changed, this merged image will usually need to be changed.

Summary: Generally, CSS Sprites combined layout is used for local small box layout and is not suitable for large backgrounds and large layout backgrounds. For example, small partial layout, small icon background, small navigation background and other CSS layouts. In short, many times we have to weigh the pros and cons before deciding whether to use CSS Sprites.

Three. Give me a chestnut

A picture of Emoji

                                                           

Final effect:

html code:

    
Copy after login

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;
    }
Copy after login

 

Related labels:
source:php.cn
Statement of this Website
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 [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!