Suckerfish Drop Downs With Varying Sized Images
This was another challenging coding project I was asked to do. You can see the results at YP4.org. As you can see, the top menu requires images, each a different width. The height remains the same but because of the offset text on rollover, using text to trigger the menu was not an option. I did a bit of research and found this really old gem of a tut by Eric Meyer. I decided to try it, since nothing else was working. The difference was that when I created the transparent gif, for each menu item I changed its width in the img tag to match the width of the actual image. Then I set the nav image to be the background image. So these are triggered by transparent gifs. For each and every menu item I created, I followed Eric Meyer’s directions at the link above. I ended up with this:
/**(SET THE FIRST ONE JUST ONCE)**/
li a img {height: 52px; border-width: 0; border-right:1px solid #e9e9e9;}
li a#about {background:url(../images/nav/nav_about.gif) top left no-repeat;}
li a#about:hover {background: url(../images/nav/nav_about_over.gif) top left no-repeat;}
Remember that I had to define the background image and hover image for each one of those ID’d links, 6 in total. Not the most economical coding, perhaps, but it did the trick. AND it allowed my Son of Suckerfish menus to work very nicely underneath it.
The caveat to this this trick is that it ALSO required some extra coding for the Suckerfish menus to work properly. This code allows the top level “over” state to remain on when you are mousing over the drop downs. Again, this has to be repeated for every link.
#mainNav li:hover a#about, #mainNav li.sfhover a#about{
background:url(../images/nav/nav_about_over.gif) top left no-repeat;
}
EVERYTHING on the top level menu is an image, except for the grey border on the left which I defined in that top line of CSS. The next trick was to match the shadows AND borders for the drop downs, which is completely rendered with CSS. The only image I used here was to help me create the shadow that underlies the whole drop down - a small red triangle.
