How can a png picture have multiple icons and how to use them?

clipboard.png

Jul.07,2021

this is commonly known as CSS sprite , and its English name is CSS Sprite

.

usage and the purpose and principle of doing so have been explained in Baidu encyclopedia. I will give you a link

.

CSS Sprite


get the png icon


sprite image by setting the location and size of background, and capture it according to the position of the upper-left corner of each small picture. Your designers are more responsible


you can use background-position processing


sprite images, and you can use background-size + background-position to modify them.


this png diagram with many small icons is called CSS sprite.
if a site uses a lot of small icons, it's best to use PS to sort out these small icons on a large png.
organized into a png, you can request icons only once from the server (because all icons are on this png), reducing the number of requests the page faces to the server, and performance is improved.
as for usage, like a single small icon, just set the background image, then measure the position of the small icon on the large png (the size on the top and left), and set the background-position.


use background-position to get the position of the small icon in the sprite image;

Menu