Home arrow HTML arrow Page 4 - Quick Web Page Menu
HTML

Quick Web Page Menu


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.

Author Info:
By: Chrysanthus Forcha
Rating: 5 stars5 stars5 stars5 stars5 stars / 8
April 30, 2008
TABLE OF CONTENTS:
  1. · Quick Web Page Menu
  2. · Strategy
  3. · Code continued
  4. · Explanation of Code

print this article
SEARCH DEVARTICLES

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).

In the BODY element, we have a one row table. The two table cells of interest have the onclick event that will call the JavaScript function to make the DIV element (pull down menu) visible. When the table cell content is clicked, the function is called with the id of the corresponding DIV element passed to it.

Now let us look at the JavaScript. There are two functions here: one to make the DIV element (pull down menu) visible and the other one to hide (close) all menus when the user clicks on the body element outside the menu. The first function hides all the pull-down menus that might be visible (opened) before making visible the menu of interest.

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.

Finishing

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.

Conclusion

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.

blog comments powered by Disqus
HTML ARTICLES

- Does HTML5 Need a Main Element?
- Revisiting the HTML5 vs. Native Debate
- HTML5: Not for Phone Apps?
- HTML5 or Native?
- Job Hunting? Freelancer.com Lists This Quart...
- HTML5 in the News
- Report: HTML5 Mobile Performance Lags
- The Top HTML5 Audio Players
- Top HTML5 Video Tutorials
- HTML5: Reasons to Learn and Use It
- More of the Top Tutorials for HTML5 Forms
- MobileAppWizard Releases HTML5 App Builder
- HTML5 Boilerplate: Working with jQuery and M...
- HTML5 Boilerplate Introduction
- New API Platform for HTML5

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials