Jump to content

CSS sprites for image backgrounds and UI Images?


random1

Recommended Posts

There are about a million tutorials on the net.

 

But the concept is pretty simple. Take both your images and turn them into one image (side by side, or top and bottom). Make sure both images are exactly the same dimensions. Make the container exactly the same size as one of the images (which is now half the image). Set the normal state image as the background (it should be at the top left of your image, regardless of whether you combined images is top/bottom or left/right). On hover, change the background image position by a negative of the size of the image.

Link to comment
Share on other sites

But the concept is pretty simple. Take both your images and turn them into one image (side by side, or top and bottom). Make sure both images are exactly the same dimensions.

 

That's a pretty limited use of sprites and it's definitely not necessary for the images to be the same dimensions.

 

Just look at how amazon.co.uk uses a large sprite for all the main UI images - http://g-ecx.images-amazon.com/images/G/02/gno/images/orangeBlue/navPackedSprites_v13._V219533094_.png

 

The key is simply to produce a single matrix of images that is then positioned as a background image where needed.

Link to comment
Share on other sites

The guy said himself that he can't wrap his head around it. I gave him a basic solution at a level he can grasp. Sure there are more complicated ways it can be used, but everything you said is a little overwhelming for someone who hasn't even got the basics down yet.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.