NavBar Menu List with CSS

The Overview:

An interactive navigation bar using CSS with rounded corners. Just put the html as an unordered list and your navigation links as list items and the CSS will do the rest! As shown here! The css will tell the browser to display this special unordered list as the menu. This utilizes a technique to have one background image with three states: normal, hover and active. The css controls the placement of the background image so when you hover, the images is displaced to show only the hover state, and likewise for the active and then returns to the normal state. This is compatible in all the browsers I have checked so far, let me know if you find any issues [thanks].
vertical nav menu screenshot

The Steps:

1. First make the html. An <ul> full of <li> elements.

2. Make the desired backgrounds. Three part background (or two) . One part ‘Normal’ state and another ‘hover’ state and optionally an ‘active’ state. Add additional backgrounds if you want anything like rounded corners, or just a header.
menuTop
Top Menu Background Image
menuMiddle
Middle Menu Background Image
menuBottom
Bottom Menu Background Image

3. The CSS to attach the two together

The Example:

verticalMenuCSS.html

As you can see this is a simple html unordered list with list items.

<ul>
<li class="top">My Site</li>
<li class="middle">Home</li>
<li class="middle">About</li>
<li class="middle">Biography</li>
<li class="middle">Portfolio</li>
<li class="bottom">Contact</li>
</ul>

Here’s the magic.

/*vertical Menu CSS style sheet*/

*{
  list-style:none;
  margin:0px;
  padding:0px;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 1em;
}

.sidemenu {
  width: 150px;
  border: none;
}
.sidemenu li a {
  height: 18px;
  text-decoration: none;
}
/*Top sidemenu Item (Header and rounded corners)*/
.sidemenu li.top a:link, .sidemenu li.top a:visited {
  color: #828282;
  display: block;
  background: url(images/menuTop.png);
  background-repeat:no-repeat;
  padding: 1px 0 1px 0;
  font-size: 1em;
  font-weight: bold;
  text-align: center;
}
/* Uncomment this if you want the header to be an interactive link
.sidemenu li.top a:hover {
  color: #828282;
  background: url(images/menuTop.png) 0 -22px;
}
.sidemenu li.top a:active {
  color: #26370A;
  background: url(images/menuTop.png) 0 -44px;
}*/


/*sidemenu Item Middle*/
.sidemenu li.middle a:link, .sidemenu li.middle a:visited {
  color: #5E7830;
  display: block;
  background: url(images/menuMiddle.png);
  background-repeat:no-repeat;
  padding: 1px 0 1px 20px;
  font-size: 0.8em;
}
.sidemenu li.middle a:hover {
  color: #FFFFFF;
  background: url(images/menuMiddle.png) 0 -22px;
}
.sidemenu li.middle a:active {
  color: #FFFFFF;
  background: url(images/menuMiddle.png) 0 -44px;
}

/*Bottom sidemenu Item (rounded corners)*/
.sidemenu li.bottom a:link, .sidemenu li.bottom a:visited {
  color: #5E7830;
  display: block;
  background: url(images/menuBottom.png);
  background-repeat:no-repeat;
  padding: 1px 0 1px 20px;
  font-size: 0.8em;
}
.sidemenu li.bottom a:hover {
  color: #FFFFFF;
  background: url(images/menuBottom.png) 0 -22px;
}
.sidemenu li.bottom a:active {
  color: #FFFFFF;
  background: url(images/menuBottom.png) 0 -44px;
}

verticalMenuCSS.html

The Download:

verticalMenuCSS.zip

This entry was posted in tutorial and tagged , , , , , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

One Comment

  1. Dion
    Posted December 14, 2007 at 5:50 pm | Permalink

    That’s great, thanks. Easy to use and fast! kudos

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  • Recent Posts

    WordCamp Presentation Slides: From Photoshop PSD to WordPress Theme

    Here are my slides for my WordCamp Atlanta presentation, From PSD to WordPress Theme: Under the skin: PSD to WP on Prezi Tweet

    wordpress_wordcamp_atlanta_2012_feb_2_3

    Speaker at WordCamp Atlanta 2012

    I’m proud to announce that I’ve been asked to speak at WordCamp Atlanta this year! WordCamp will be held this weekend and hosted at SCAD Atlanta! My session is titled: From PSD to WordPress Theme: Under the skin. Obviously, I’ll be focusing on themes. We’ll look at what they are, what they can do, how [...]

    Adobe-like Arrow Headers | CSS-Tricks

    Zero images is something that always gets me excited, I really like these arrow button styles! I like the css used more and the hover/active states too, nice css3 transitions. via Adobe-like Arrow Headers | CSS-Tricks. Tweet

    snow

    Snow via Javascript & Canvas – Tis the Season

    After playing with the settings in my experiments I found a few settings I liked and wanted to develop further. The first was snow! An added bonus I was able to work on a project just for the holidays and used much of this code in it! I looked around the web and saw a [...]

  • Recent Shares

    bio

    An Event Apart Notes: Ethan Marcotte, Responsive Web Design

    Ethan Marcotte has become the father of Responsive Web Design and spent this whole day focused on principles, techniques, gotchas, examples, … all about building and how to build responsive sites. With a sprinkle of mobile first. For Ethan, it all started with this article: http://www.alistapart.com/articles/dao/ Think of architecture, the whole design phase is established [...]

    sammyj

    An Event Apart Notes: Ethan Marcotte, Rolling Up Our Responsive Sleeves

    Henry Adams (Descendant of 2 presidents: great-grandson to John Adams and grandson to John Quincy Adams). He lived between the civil war and world war 1. He witnessed the industrial revolution. Chaos was the law of nature, Order was the dream of man Samuel Johnson – funniest man in the 17th Century… Responsive Design: 1. [...]

    Webcomm_Montreal

    An Event Apart Notes: Jared Spool, The Curious Properties of Intuitive Web Pages

    Senseless waste of asterisks… Avis used an asterisk to denote optional fields. This means that there is a lot of baggage that comes with an asterixk. Somewhere this symbol got meaning, it’s not in the bible! We can control when something goes from unintuitive to intuitive. A design is intuitive (although technically and grammatically speaking [...]

    untitled-158-2

    An Event Apart Notes: Marco Arment, Bridging the App Gap

    The iPhone changed our industry in 2007: first mobile to have a desktop class web browser and it made people start using their mobile phones as computers! All apps other than apple provided ones were web browser apps. Most of the first apps were branded web browsers. No real difference between using mobile site or [...]

  • Recent Comments

    Lori Newman

    Lori Newman

    Just wanted to thank you for your presentation. It was extremely informative and just what I...
    Karl

    Karl

    I have been using for some time this nice Banner, from developer FX. They have a really nice Live...
    Karl

    Karl

    Thank you for this wonderful link… recommend it! Fast, simple, easy… :-)
    Gabriel

    Gabriel

    Hi Valerie, I don’t know if you are still following this post, but I tried seeing if it is...
    avinash

    avinash

    Hi Evan, I am using the same code and trying it on chrome/firefox it is not working on neither...
    Matt

    Matt

    I needed to store url variables from advertising tracking servers – this method works like a...