| Downloaded from www.biorust.com on Thu Feb 09, 2012 09:11:06 |
![]() | |
| CSS Navigation Menus Tutorial Author - Jacorre (http://www.jacorre.com) |
Are you looking to create
navigation menus using CSS? Are you looking to use
different styles for your navigation menus? This
tutorial will teach you how to create different menu
styles for a main menu, submenu, and footer menu.
STEP ONE
First, we have to create the html for the actual
menus. The following html is for the main menu. Take
note that the id is called "main-menu" for the div .
Also, take note that the Resources link has a class
called "active":
| <div id="main-menu"> <ul> <li><a href="index.htm">Home</a></li> <li><a href="services.htm">Services</a></li> <li><a href="portfolio.htm">Portfolio</a></li> <li><a class="active" href="resources.htm">Resources</a></li> <li><a href="contact.htm">Contact</a></li> </ul> </div> |
| <ul class="submenu"> <li><a class="active" href="tutorials.htm">Tutorials</a></li> <li><a href="downloads.htm">Downloads</a></li> <li><a href="affiliates.htm">Affiliates</a></li> <li><a href="links.htm">Links</a></li> </ul> |
| <div id="footer"> <a href="terms.htm">Terms of Use </a> | <a href="privacy.htm">Privacy Policy </a> </div> |
/* Remove all margin and padding
from the unordered list in the main menu. */ |
This should be the result for
the main menu:

So as you can see, if you're on the Resources page,
it will display in a different color and be
underlined. If you were on the Contact page, you
would add the class of "active" to the Contact link.
STEP THREE
The following CSS is for the submenu:
/* Set margin to 0 and add 20 pixels of padding to
the bottom and 10 pixels of padding to the left of
the unordered list. Also, remove bullets from the
unordered list. */ |
This should be the result for
the submenu:

So as you can see, if you're on the Tutorials page,
it will display in a different color. If you were on
the Downloads page, you would add the class of
"active" to the Downloads link.
The reason why I created it as a class is because I
can use this style multiple times on a page. So if I
wanted to create another unordered list, I could use
the same styles for it. That's the difference
between using an id and a class. An id is used only
once on a page whereas a class can be used multiple
times on a page.
STEP FOUR
The following CSS is for the footer:
/* Links within the footer will appear with white
text and the font size will be 95%. Because we
haven't defined any text decoration, the default is
underlined. */ |
This should be the result for
the footer:

There you have it! Three different menus, each with
their own unique styles. Enjoy!