Many applications (e.g. Microsoft Word) have a menu as their first bar. If you have a web site that has many pages, you can create a similar menu bar where, if you click a menu item, a drop-down menu with links will appear over other content on the page. You might have seen this on some web pages already. Keep reading if you would like to learn how to build this for your web site.
Quick Web Page Menu - Explanation of Code (Page 4 of 4 )
This paragraph explains what we have in the Style Sheet.
We do not want to change the position of the body element, so we give it a relative position property. We give it a z-index of 0. The CSS class name "menu" has been given to differentiate the table from any other table you can have on your web page. The one row table for the menu has been given the background-color: Fuchsia. To make this tutorial simple, I assumed that the only DIV elements are the two DIV elements we have for drop-down menus. The DIV elements have been given the absolute position property, a z-index of 20, and a background color of fuchsia. The DIV elements are all initially made hidden (closed). The DIV elements have been given background colors so that when they are made visible (opened) the user will not see the elements behind them (the pull down menus).
The second function responds to the onclick event (hideMenus()) of the body element. The problem here is that when you click on the menu bar or on the body outside the menu, this function is called. The two Boolean variables (menuClicked and onlyBodyClick) are used to distinguish between clicking on the menu bar and clicking on the body outside the menu.
If you give the above table, table cells and DIV elements sizes and then give suitable colors to your links, background of DIV and TD elements, you should have a reasonable menu which is quickly designed. Note: the colors you choose depend on the overall design and colors of you web page. I have not specified them to any great degree in order to simplify this tutorial.
The above process gives you a reasonable and quick design. If you want to design a menu for commercial purposes, you have to take details into consideration. For example, the items in the drop-down menu may form a list, with graphical bullets. You have to think about sub menus for the drop-down menus. You have to think about style and even animation. The basics, however, you already know from this article. GOOD LUCK.
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.