Multiple Background Images using Sass / Compass

Matrym picture Matrym · May 1, 2011 · Viewed 7.6k times · Source

The following generates a base64 inline-image using sass/compass:

background-image:inline-image("paper.jpg", 'image/jpg');

Is there a way to do multiple background images, or do I have to precompress them myself to do it?

Thanks.

Answer

Beau Smith picture Beau Smith · May 10, 2011

The inline-image function just outputs the url() string, so you can use multiple by doing this:

background: inline-image("front-image.jpg", 'image/jpg') no-repeat, inline-image("back-image.jpg", 'image/jpg') repeat-x

And you'll get the following css:

background: url('data:"image/jpg";base64,FRONTIMAGEDATAHERE') no-repeat, url('data:"image/jpg";base64,BACKIMAGEDATAHERE') repeat-x;

I added "no-repeat" and "repeat-x" otherwise the front-image will repeat and cover the back-image.