/ Published in: CSS

One of the great methods to load and work with icons in web pages is to load one image that is a collection of several icons and use any icon as needed, that reduces the number of server request and save bandwidth.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<style> div.img1{ width:32px; /* width of selected icon */ height:32px; /* height of selected icon */ background:url(http://mysite/image.png) -130px -16px; /* the position of icon in the main image */ } div.img2{ width:29px; height:27px; background:url(http://mysite/image.png) -35px -2px; } </style> <body> <div class="img1"></div> <div class="img2"></div> </body>
URL: http://function-code.blogspot.com/2013/03/image-sprites-get-portion-of-image.html
Comments
