Thursday, June 18, 2009

CSS Horizontal Menu (1)


Whoa, I've been busy lately so this is my first post in 2 months. I'll put up a couple of horizontal menus I used recently on a few different websites.

This menu is css driven - by a unordered list (as most menus will be on this blog). I use images for background sometimes, but making sure that adding a new menu item at a later date is adding 1 line to the list, instead of having to create on/off images.

There are two images used for
a) the shaded background
b) the item divider,

Here is the css, html and the images are included too.

/** Horizontal Menu **/
#menu {display:block;width:975px;margin:auto; }
#menu ul {list-style:none;background:url(../images/background_menu.jpg) repeat-x;
height:35px;margin:0;padding:0 0 0 10px;font-size:15px;}
#menu ul li {margin-top:2px;float:left;padding:3px 15px 0 15px;background:url(../images/menu_divider.jpg) no-repeat right top;}
#menu ul li a{text-decoration:none;color:#171a29;}
#menu ul li a:hover{text-decoration:underline;}

HTML:
<div id="menu">
<ul>
<li><a href="">Home</a></li>
<li><a href="">About</a></li>
<li><a href="">Services</a></li>
<li><a href="">Events</a></li>
<li><a href="">Advertising</a></li>
<li><a href="">Contact Us</a></li>
<li><a href="">Directions</a></li>
</ul>
</div>

Images

2 comments:

  1. Hi Conor,

    I tried this example by running the HTML.
    Everything looks great except that at the end of the navigation bar that is created, I am getting an extra menu divider and an extra blank tab.
    In your example there are 7, tabs the last one being "Directions", but when I run the HTML an extra empty tab comes out to the right of the "Directions" tab.
    How can I get rid of the extra menu-divider and extra tab?
    Here is my e-mail if you want to answer me:
    savmoy@videotron.ca
    I will also ask you this question on the web forum in case you see it there first.

    Thanks again for the help and the great info you have provided me with!
    Maurice

    ReplyDelete
  2. Hi Maurice
    Yes I seen your comment first on the webgroups so responded there, all should work (even if the image is slightly different.
    Ping me at my email if you need more help
    Best
    -c

    ReplyDelete