CSS Sprite image creation, CSS Sprite Image
CSS Sprite:
To improve web page performance and reduce loading times, place small icons that do not change frequently with the website content on a large image and embed the image into the page as a background-image, set the coordinates based on background-position when you need to associate the map.
For example, you can copy and view the results:
HTML code:
<! DOCTYPE html>
CSS code:
/* General settings */. container ,. menu {margin: 0; padding: 0; line-height: 0;} a: link, a: visited {text-decoration: none; color: inherit;}: hover {color: orangered;}/* format setting */. menu {width: 120px; list-style-type: none; border: 1px solid # ccc ;}. menu li {display: block; height: 31px; line-height: 31px;} li h3 {font-size: 14px; font-weight: 400; border-bottom: 1px solid # eee;} li I {background: url ("img/sprite.png"); display: inline-block; float: left; width: 24px; height: 24px; margin: 0 15px 5px ;}. cat-1 I {background-position: 0 0 ;}. cat-2 I {background-position: 0-26px ;}. cat-3 I {background-position: 0-52px ;}. cat-4 I {background-position: 0-78px ;}. cat-5 I {background-position: 0-pixel PX ;}. cat-6 I {background-position: 0-130px ;}. cat-7 I {background-position: 0-156px ;}. cat-8 I {background-position: 0-182px ;}. cat-9 I {background-position: 0-208px ;}. cat-10 I {background-position: 0-236px ;}
This is a graph created using a Sprite online production tool. Link: http://lazytools.sinaapp.com /. Other tools are not clear, but the tool will generate CSS information for the position corresponding to the icon at the end, which can be used directly, very convenient.
The following is the final result:
Conclusion: for beginners, learning a new knowledge point requires more exercises and writing code by themselves. It does not work when watching videos, in practice, various problems may occur, and multiple exercises are also the best way to keep improving.
I don't know if you know how to make and use sprite images. Now I will.