Image sprites with Compass
CSS sprite images is a technique that dates back many years. All the website's images are added to a single image, the sprite. If the browser requests an image, the sprite will be loaded as the background image. CSS is used to show the requested image containing a part of the sprite. Loading one big sprite, which can be cached, instead of several small images will reduce the number of HTTP requests needed by the browser to show the page. The fewer the HTTP requests, the faster the page will load.
Getting ready
For this recipe, you have to install both Sass and Compass. Read the Installing Sass for command line usage and Installing Compass recipes of Chapter 1, Getting Started with Sass.
You will also need some PNG images and to create a file and directory structure like that shown in the following image:
How to do it...
Learn how to create image sprites for your projects with Sass and Compass by following the steps as shown:
Create an
images/logos
folder in your project...