Css Sprite (Sprite chart, sprite chart) < image flattening Technology >

Source: Internet
Author: User

One, the sprite diagram usage scene:

Second, Css Sprite (merit)
    1. Reduce the byte of the picture.
    2. Reduce Web page HTTP requests, which greatly improve the performance of the page.
    3. Solve the web designer in the image naming problems, just a set of pictures named on it, do not need to name every small element, thus improving the production efficiency of the page.
    4. Changing style is convenient, just need to change the color or style of the picture on one or fewer pictures, the whole page style can be changed. More convenient to maintain.
Three, the realization principle CSS Background-position

Controls the area range size that a layer can display,
Slide the background image through a window
Instance:

The code is as follows:

<!doctype html>"Utf-8"/> <title>background-Position<</title> <link rel="Stylesheet" href="Index.css"/> class="Oo span1" ></span> <spanclass="Oo span2" ></span> <spanclass="Oo span3" ></span> <spanclass="pp Span4" ></span> <spanclass="ll Span5" ></span> <spanclass="HH span6" ></span> </body>0AutoText-align:center;}. oo{Display:block;Width43px;Height44px;Background:url (images/img_navsprites_hover.gif) no-repeat; Margin20pxAuto;}. span1{background-Position00;Position:absolute; Top0px;}. span2{background-Position-47px0;Position:absolute; Top0px; Left60px;}. span3{background-Position-94px0;Position:absolute; Top0px; Left120px;}. span1:hover{background-Position0-45px;}. span2:hover{background-Position-47px-45px;}. span3:hover{background-Position-94px-45px;}. pp{Display:block;Width38px;Height38px;Background:url (images/pwd-icons-New.png) No-repeat; Margin20pxAuto;}. span4{background-Position-48px-96px;}. ll{Display:block;Width24px;Height26px;background:url (Images/tb1eixtxlth8kjjy0fixxcrsxxa-24< Span class= "Hljs-number" >-595.png) no-repeat; Margin:20px auto;}. span5{background-position:0 Span class= "Hljs-number" >-483PX;}. hh{display:block; width:18PX; height:18PX; background:url (images/toolbars.png) no-repeat; Margin:20px auto;}. span6{background-position:- 95px -211px;            

**background-position:npx npx;
(The first value is the left and right, when you need to turn the background map to a positive value, negative to the left to the same time the background map is transferred up and down with a negative value, the next is positive)**
<2> as follows:
(This is the original)

(This is the image after the election)

The first picture is the conversion of the original image and the Dark One, the lock of the second picture, the train of the four picture, and the villain of the figure.

Just into the front end write bad forgive!!! (^o^)/~

Css Sprite (Sprite chart, sprite chart) < image flattening Technology >

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.