{"id":724,"date":"2010-07-14T00:44:07","date_gmt":"2010-07-14T00:44:07","guid":{"rendered":"http:\/\/www.phpmind.com\/blog\/?p=724"},"modified":"2010-07-17T01:35:43","modified_gmt":"2010-07-17T01:35:43","slug":"what-is-css-image-sprites","status":"publish","type":"post","link":"https:\/\/www.phpmind.com\/blog\/2010\/07\/what-is-css-image-sprites\/","title":{"rendered":"What is CSS Image Sprites?"},"content":{"rendered":"<p>An image sprite is a collection of images put into a single image.<\/p>\n<p><strong>What is advantage of using image sprite? <\/strong><\/p>\n<ol>\n<li>Reduce multiple server requests.<\/li>\n<li>Sprites reduce the number of server requests and save bandwidth.<\/li>\n<li>Another advantage of sprites is that you can keep all your images in one  location and in some cases it makes more sense (for menus and so on).<\/li>\n<\/ol>\n<p><strong>A real life Example <\/strong><br \/>\nIf you use sprites for a &#8220;mouse over&#8221; display, the user won\u2019t experience image disappear for a second&#8230; and it looks really good when you have heavy graphics in your site.<br \/>\nIf you change the image instead of just moving the sprite around it will load a new image and the loading time can be visible to the end user.<\/p>\n<p><strong>CSS Image Sprites Example Code<\/strong><\/p>\n<pre lang=\"css\">.NotGood{\r\n\r\n  background:url(sprites.jpg);\r\n\r\n}\r\n\r\n.NotGood:hover{\r\n\r\n  background:url(spritesHover.jpg);\r\n\r\n}\r\n\r\n.Good{\r\n\r\n  background:url(sprites.jpg) 0px 0px;\r\n\r\n}\r\n\r\n.Good:hover{\r\n\r\n  background-position:15px 0px;\r\n\r\n}\r\n<\/pre>\n<p>You can use Adobe Photoshop or any other image editing software to determine which area needs to be display.<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/www.phpmind.com\/blog\/wp-content\/uploads\/2010\/07\/phpmind-css-sprint.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-725  aligncenter\" title=\"phpmind-css-sprint\" src=\"http:\/\/www.phpmind.com\/blog\/wp-content\/uploads\/2010\/07\/phpmind-css-sprint.png\" alt=\"\" width=\"445\" height=\"248\" srcset=\"https:\/\/www.phpmind.com\/blog\/wp-content\/uploads\/2010\/07\/phpmind-css-sprint.png 445w, https:\/\/www.phpmind.com\/blog\/wp-content\/uploads\/2010\/07\/phpmind-css-sprint-300x167.png 300w\" sizes=\"auto, (max-width: 445px) 100vw, 445px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>An image sprite is a collection of images put into a single image. What is advantage of using image sprite? Reduce multiple server requests. Sprites reduce the number of server requests and save bandwidth. Another advantage of sprites is that you can keep all your images in one location and in some cases it makes [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[28],"tags":[],"class_list":["post-724","post","type-post","status-publish","format-standard","hentry","category-css"],"_links":{"self":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts\/724","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/comments?post=724"}],"version-history":[{"count":5,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts\/724\/revisions"}],"predecessor-version":[{"id":830,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts\/724\/revisions\/830"}],"wp:attachment":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/media?parent=724"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/categories?post=724"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/tags?post=724"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}