Home Contact RSS

NavBar Menu List with CSS

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

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

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.

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.

  1. <ul>
  2. <li class="top">My Site</li>
  3. <li class="middle">Home</li>
  4. <li class="middle">About</li>
  5. <li class="middle">Biography</li>
  6. <li class="middle">Portfolio</li>
  7. <li class="bottom">Contact</li>
  8. </ul>

Here’s the magic.

  1. /*vertical Menu CSS style sheet*/
  2.  
  3. *{
  4. list-style:none;
  5. margin:0px;
  6. padding:0px;
  7. font-family: Arial, Helvetica, sans-serif;
  8. font-size: 1em;
  9. }
  10.  
  11. .sidemenu {
  12. width: 150px;
  13. border: none;
  14. }
  15. .sidemenu li a {
  16. height: 18px;
  17. text-decoration: none;
  18. }
  19. /*Top sidemenu Item (Header and rounded corners)*/
  20. .sidemenu li.top a:link, .sidemenu li.top a:visited {
  21. color: #828282;
  22. display: block;
  23. background: url(images/menuTop.png);
  24. background-repeat:no-repeat;
  25. padding: 1px 0 1px 0;
  26. font-size: 1em;
  27. font-weight: bold;
  28. text-align: center;
  29. }
  30. /* Uncomment this if you want the header to be an interactive link
  31. .sidemenu li.top a:hover {
  32. color: #828282;
  33. background: url(images/menuTop.png) 0 -22px;
  34. }
  35. .sidemenu li.top a:active {
  36. color: #26370A;
  37. background: url(images/menuTop.png) 0 -44px;
  38. }*/
  39.  
  40. /*sidemenu Item Middle*/
  41. .sidemenu li.middle a:link, .sidemenu li.middle a:visited {
  42. color: #5E7830;
  43. display: block;
  44. background: url(images/menuMiddle.png);
  45. background-repeat:no-repeat;
  46. padding: 1px 0 1px 20px;
  47. font-size: 0.8em;
  48. }
  49. .sidemenu li.middle a:hover {
  50. color: #FFFFFF;
  51. background: url(images/menuMiddle.png) 0 -22px;
  52. }
  53. .sidemenu li.middle a:active {
  54. color: #FFFFFF;
  55. background: url(images/menuMiddle.png) 0 -44px;
  56. }
  57.  
  58. /*Bottom sidemenu Item (rounded corners)*/
  59. .sidemenu li.bottom a:link, .sidemenu li.bottom a:visited {
  60. color: #5E7830;
  61. display: block;
  62. background: url(images/menuBottom.png);
  63. background-repeat:no-repeat;
  64. padding: 1px 0 1px 20px;
  65. font-size: 0.8em;
  66. }
  67. .sidemenu li.bottom a:hover {
  68. color: #FFFFFF;
  69. background: url(images/menuBottom.png) 0 -22px;
  70. }
  71. .sidemenu li.bottom a:active {
  72. color: #FFFFFF;
  73. background: url(images/menuBottom.png) 0 -44px;
  74. }

verticalMenuCSS.html

The Download:

verticalMenuCSS.zip

Tags: , , , , , , ,

Related posts

flashden banner

Gravatar

Dion said,

December 14, 2007 @ 5:50 pm

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

RSS feed for comments on this post · TrackBack URI

Leave a Comment