There are two states of a sub menu item generally. In the code we have been talking about so far, when a menu item appears, it is brown; when the mouse pointer goes over it, it is firebrick. This is done by changing the background color of the table cell of the sub menu item. In this part of the series I show you how you can use two images instead of two background colors to indicate these two states of a sub menu item. This is the final part of a ten-part series on building a common menu browser.
Finishing Touches for a Common Browser Menu (Page 1 of 5 )
The code in this series works very well with Internet Explorer, Mozilla Firefox and Netscape. The majority of users worldwide use one of these three browsers. Even though the aim of this series is to come up with a menu that can work with as many browsers as possible, as an extra touch I'm going to show you how you can add code so that it would work with other browsers as well.
Using Images for Cell Background
In this section we shall see how to use an image as background for a table cell of a sub menu item. This is how it goes: when a sub menu is displayed, you should see one particular background image in all of the cells. When the mouse pointer goes over a sub menu item you should see a different background image. When the mouse pointer moves away from the menu item, you see the initial (default) image.
We shall modify the previous code in order to fit these images into it.
Use your drawing tool and design two different images. Give each of them the dimensions of the table cells of the sub menus; all of these table cells have the same dimensions. In the code I will give you, the name of the image which appears with any sub menu item is normal.gif. When the mouse pointer goes over the item, the name of the image which then appears is over.gif. I will use these names to explain how you change the previous code to work with images.