O'Reilly logo

Sass and Compass Designer's Cookbook by Bass Jobsen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required