This article to you to share is about CSS sprite how to achieve image flattening technology, the content is very good, there is a need for friends to refer to, hope can help everyone.
One, the sprite diagram usage scene:
Second, Css Sprite (merit)
Reduce the byte of the picture.
Reduce Web page HTTP requests, which greatly improve the performance of the page.
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.
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>
**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.