#home-link { display: block; width: 150px; height:25px; background:url(/images/home-nav.gif) top left no-repeat; }
The image has **both** the normal and mouseover state, with the normal at top
------------ --- HOME --- ------------ --- HOME --- <-- mouseover ------------
then
.main-nav:hover { background-position: 0 -25px; }
the numbers may be incorrect, but you get the idea, play with it. The idea is to shift the background up by the height of the button.)
If all your images are the same size, you can use the class, otherwise you may need to use
#home-link:hover
instead.
This loads both normal and hover at the same time in one image, faster loading, no delay for second image to load, no Javascript required.
morehawes
10:01 am on Aug 31, 2010 (gmt 0)
None of those . . . CSS. :-)
Agreed.
One little addition that I use when you have the background-position of the 'normal' state set to 'top left' you can set the hover position using keywords :