top image for the content

Learning Report No. 07: Image Sprites

sources

w3schools

What I learned

An image sprite is a collection of images put into a single image; only a portion of the image is viewed at a time. When one portion of the image is shifted to reveal the other it gives the roll-over affect without excessive requests to the server.

How I implemented it

When mocking up this site I wanted to have a texture appear under the navigation bar links as the user rolls over each link.
First I had to create the sprite images, I used photoshop. I created the swatch that I wanted, and then doubled the canvas height.
The highlight image sprite I created for in photoshop
Then I tried to implement the sprite on my navigation bar, but decided it would be easier if I tested how it worked on a separate HTML document with only the sprite CSS to make sure that I knew how it worked.
The CSS I used to create a working image sprite
what the working image sprite text looks like when the cursor hovers over the link
Then I tried to implement image sprites on my navigation bar on a test page. I am still having trouble adjusting the measurements to that the highlights land directly under the text.
Now the tricky part is combining the CSS so that it will work on my site. And as you can see at the top of this screen, I was able to accomplish it.

bottom image for the content