CSS Sprites Repeating Images

fhd picture fhd · Jul 28, 2010 · Viewed 12.6k times · Source

I was wondering if there is any way to use just one image for repeating and non-repeating images using css sprites. So in this case I would like to combine all the images on a page no matter what width and height and if they will be used as repeating or non-repeating images. I know the standard is to create 1 image using all the non-repeating images and another image using all the repeating images. But i just wanted to know if i could just use 1 image for everything.

Thanks.

Answer

Ryan Kinal picture Ryan Kinal · Jul 28, 2010

The short answer is "no".

The explanation is that repeating images are displayed in their entirety in whatever direction they repeat. So, a background that is set to repeat-x will show all image content in the horizontal direction. This is why you can't repeat in both directions simultaneously using sprites.