Home > Article > Web Front-end > Part 5 of the series on the skillful use of photoshop for front-end engineer skills - Sprite pictures
As mentioned before, descriptive pictures will eventually be merged into sprite pictures. This article is the fifth article in the series of photoshop skillful uses - Sprite
CSS sprite (sprite) is a web image application processing method that allows you to All scattered images related to a page are included in one large image. Using the sprite image processing method can achieve two advantages:
【1】Reduce the number of http requests
【2】Reduce the image size and improve the web page loading speed (the loading speed of multiple images is less than that of a combined image) Loading speed of synthesized images)
Everything is not perfect. While achieving the advantages, it also brings disadvantages, that is, it increases the development and maintenance costs of the web page.
As mentioned earlier, not all pictures can be used to make sprite pictures, only descriptive pictures are suitable
【1】Content pictures set in the img tag cannot be merged into sprite images. Merging these pictures will affect the readability of the page, reduce the semantics and the adjustable range is small
【2】For Images that are tiled both horizontally and vertically cannot be merged into sprite images. If it is tiled horizontally, all the pictures tiled horizontally can only be merged into one large picture, which can only be arranged vertically, not horizontally; if it is tiled vertically, all pictures tiled vertically can only be merged into one large picture. It can only be arranged horizontally, not vertically
The production of sprite pictures is actually to merge sporadic small pictures into one big picture, but the small pictures are merged The following rules need to be followed:
[1] The image must leave a gap before merging
1. If it is a small icon, the gap can be appropriately smaller, usually about 20 pixels
2. If it is a large icon, the gap to be left should be larger, because when the large icon is adjusted, the space affected will be larger
## 【 2] Pictures are arranged horizontally and vertically## [3] Principles of merging and classifying
There are three principles of merging and classifying, which are based on modules and based on Size and color-based
a. Merge pictures belonging to the same module
b. Merge pictures of similar size
c. Merge pictures with similar colors
##【4】Merge recommendation
In the actual sprite production , generally use two methods: one is to merge images used only on this page; the other is to merge stateful iconsImplementation In the past, we might need to manually implement the sprite image, which was a very troublesome and error-prone thing. Nowadays there are many convenient tools for making sprites. I often use a little tool called the css background merge tool. The usage method is shown in the figure below:
【Enlarge canvas】
Image-> Canvas size
# [Reduce canvas]
[Note] The color mode of PNG8 defaults to index color mode. When modifying the png8 image, you need to change its color mode to RGB mode. The steps are Image-> Mode-> ; RGB color## 2. First select the area you want to keep, and then select the image-> Crop or select the crop tool button in the toolbar to crop |
##【Move icon】 |
2. If the icon is a non-independent layer a. First use the selection tool to select the icon area, and then use the move tool to drag the icon, so that the layer can be moved b. First use the selection tool to select the icon area, then cut |