CSS - Sprites as background images

css

Solution

My question is, how do I use CSS sprites for repeated images like backgrounds?

You don't. That is simply not possible using CSS sprites. To do that, you would have to be able to specify an area of the image that is to be repeated, and to my knowledge that is impossible in both CSS 2 and 3.

Problem

I have a web application whose performance I am working to enhance. In an attempt to do this, I decided to use css sprites. I have placed all of my images in a .png file called images.png. CSS sprites have worked well for all css classes that just display an image once. However, several of my images need to be repeated. For instance, I have a banner.png image used for the banner background. Whenever I set the background-repeat property, it seems that the image does not repeat. To show my CSS definitions, here they are: ``` Before CSS Sprites ------------------ .ghwc { background-image: url(/images/layout/banner.png); background-repeat:repeat-x; color:White; width:300px; } After CSS Sprites ----------------- .ghwc { background-image: url(/images/images.png); background-repeat:repeat-x; color:White; background-position:60px 319px; width:300px; } ``` My question is, how do I use CSS sprites for repeated images like backgrounds? Thank you,

Original source