1. Concentrate all scattered background images involved in the page into a large image, and then use the large image for the web page. When a user accesses a page, they only need to send a request to the server once.
2. Directly use attributes such as background-position to accurately locate the required background part.
Example
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <div> <span></span> <span></span> <span></span> </div> </body> <style> .box span { display: inline-block; } .j { background: url("abcd.jpg") no-repeat -389px -141px; width: 102px; height: 112px; } .w { background: url("abcd.jpg") no-repeat -117px -560px; width: 135px; height: 112px; } .t { background: url("abcd.jpg") no-repeat -368px -417px; width: 102px; height: 112px; } </style> </html>
The above is an introduction to CSS sprite technology. I hope it will be helpful to everyone.