Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there limits to how tall/wide CSS Sprite-maps can be?

Let me start off by stating that I realize the arguments against doing CSS Sprites for large images. I even asked a question about why that could be considered a bad idea (and added an answer of my own). Now that we've had that talk...

I'm going to be making a large CSS Sprite-map. For the process of making this sprite-map, it behooves me to know what (if any) limit exists for the height and/or width of a sprite image in order for browsers to properly process it.

The ultimate reason behind this question is a debate over whether to lay out the sprite images in a grid or in a single row/column. For example: is it necessary or beneficial to do 4000 x 3000 instead of 400 x 30000?

Edit: The sticking point here isn't about what size images can be, but rather what size browsers can process for sprites. Given the lack of detail thus far, I'm moving forward with generating the single-large-column sprite. I'll post details of my experiences as an answer once that is complete.

like image 216
Jeffrey Blake Avatar asked Aug 26 '11 22:08

Jeffrey Blake


People also ask

How do I resize a sprite image?

You can resize your sprite using Edit > Sprite Size menu option.

Are image sprites still used?

In recent years, however, they've made a comeback. Sprite is a computer graphics term for a two-dimensional bitmap that is integrated into a larger scene. In the last few years, Facebook, Twitter, Instagram, and many other social media platforms grew like crazy.

Which of the following is a benefit of using image sprites?

The main advantage of using image sprite is to reduce the number of http requests that makes our site's load time faster. The images also load faster making switching from one image to another on some event much smoother. Image Sprite are a collection of images placed into a single image.


2 Answers

Sometimes it's more of a matter of download time. Since browsers can use multiple connections to download files, a huge image can take longer to download than a few smaller ones.

If your image is so big that it's slowing down page load maybe it's time to consider several smaller sprite images.

Direct-X 9 has a size limit if 4096 pixels, so any Internet Explorer filters applied to these elements will crop them at 4096 pixels.

See: IE display transparency bug on height > 4096px?

like image 61
Diodeus - James MacFarlane Avatar answered Sep 20 '22 18:09

Diodeus - James MacFarlane


In practice, this seems to work with no problems in Firefox 5+, Chrome, and IE7+ for a sprite image of 400x16560.

The potential issues of IE's directx rendering engine failing on images over 4096px do not create problems in IE7 or beyond; we have no method or need to test IE6 for our current project.

The one place that we experienced problems with really large spritemaps is on mobile platforms. Android devices handle them reasonably well, but iOS devices break down pretty badly, and in a strange way: They shrink the image down to fit within the dimensions they accept. So our CSS works perfectly for a small spritemap, but with no changes except increasing the physical dimensions of the spritemap image, the sprited images begin to show four times as much of the spritemap in the same html entity, with exactly the same CSS.

like image 27
Jeffrey Blake Avatar answered Sep 20 '22 18:09

Jeffrey Blake