After a few weeks away in the US, I’m back with a brand new jQuery post – this week taking a look at a new style of navigation menu. jQuery has made it simple for developers to define an idea or wireframe for a component and then implement it reasonably quickly, which has certainly helped it become the most popular JavaScript Framework out there at the moment. I feel like some of the navigation options out there right now don’t provide you with enough information about the sections of a site you can visit, so today we’re going to learn how to create a menu that solves this problem.
Here’s what we’re going to be creating in it’s final form.
First, I’m going to define what the menu can do and we’ll take a look at a rough wireframe I created using MockFlow’s free wireframe generator. We want to create a menu that appears like a standard menu bar in it’s default state, but which on rollover pulls down an information area that covers both the original menubar item and has an expanded section containing the text we want to display. This can be seen in the wireframe below.
Next, let’s begin to create this menu using some basic HTML structure and CSS. We’re going to need a holder for the menu, the menu itself, each item and a div for each of the drop-down elements we’re going to display information in.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | <div id="menuBarHolder"> <ul id="menuBar"> <li class="firstchild"><a href="javascript:#">Home</a> <div class="menuInfo">I am some text about the home section</div></li> <li><a href="javascript:#">Services</a> <div class="menuInfo">I am some text about the services section</div></li> <li><a href="javascript:#">Clients</a> <div class="menuInfo">I am some text about the clients section</div></li> <li><a href="javascript:#">Portfolio</a> <div class="menuInfo">I am some text about the portfolio section</div></li> <li><a href="javascript:#">About</a> <div class="menuInfo">I am some text about the about section</div></li> <li><a href="javascript:#">Blog</a> <div class="menuInfo">I am some text about the blog section</div></li> <li><a href="javascript:#">Follow</a> <div class="menuInfo">I am some text about the follow section</div></li> <li><a href="javascript:#">Contact</a> <div class="menuInfo">I am some text about the contact section</div></li> </ul> </div> </div> |
We’re now going to style this content. Because we only want to display the extra information for each section when a user hovers over an “li” element, we’re going to hide the information divs until they’re needed. I’ve also noticed that a lot of the popular browsers you guys use (IE aside) support CSS rounded corners, so I’m including this effect to be used for the drop-down menus – it’s visually more pleasing to the eye than corners in some designs, and if you’d prefer you can drop the last few terms in the “menuInfo” class.
This menu is completely cross-browser compatible (yay!) so it’s possible to use rounded corner definitions without needing to worry about how they’ll render in older browsers – everything should gracefully degrade as per necessary.
#menuBarHolder { width: 730px; height:45px; background-color:#000; color:#fff; font-family:Arial; font-size:14px; margin-top:20px;} #menuBarHolder ul{ list-style-type:none; display:block;} #container { margin-top:100px;} #menuBar li{ float:left; padding:15px; height:16px; width:50px; border-right:1px solid #ccc; } #menuBar li a{color:#fff; text-decoration:none; letter-spacing:-1px; font-weight:bold;} .menuHover { background-color:#999;} .firstchild { border-left:1px solid #ccc;} .menuInfo { cursor:hand; background-color:#000; color:#fff; width:74px; font-size:11px;height:100px; padding:3px; display:none; position:absolute; margin-left:-15px; margin-top:-15px; -moz-border-radius-bottomright: 5px; -moz-border-radius-bottomleft: 5px; -webkit-border-bottom-left-radius: 5px; -webkit-border-bottom-right-radius: 5px; -khtml-border-radius-bottomright: 5px; -khtml-border-radius-bottomleft: 5px; border-radius-bottomright: 5px; border-radius-bottomleft: 5px; }

Finally, let’s take a look at the jQuery for our Fluid Menu. We want to add hover cases to each element of our menu so that when a user moves their mouse over a menu-item, the information div animates into place elegantly. To achieve this, we’re simply going to use jQuery’s built-in slideDown and slideUp effects as they provide the most efficient way to achieve the effect we want with the least amount of code.
We also want users to be able to click on the entire “li” element rather than the links inside them, so we’re going to bind a pseduo-click event to all the menu’s li’s by means of document.location.href and an attribute check on the href of their child links.This is achieved as follows:
$(document).ready(function() { $('#menuBar li').click(function() { var url = $(this).find('a').attr('href'); document.location.href = url; }); $('#menuBar li').hover(function() { $(this).find('.menuInfo').slideDown(); }, function() { $(this).find('.menuInfo').slideUp(); }); });
and that’s it!. You can now easily set additional information for any of the menu items in your menu-bar and if needed you can easily extend the length of the drop-downs to suit your needs. You can find a demo and download links to all of the code in today’s post below.
Demo: http://addyosmani.com/resources/fluid-menu/fluid-menu.html
Download: http://addyosmani.com/resources/fluid-menu/fluid-menu.zip



I just really dig JavaScript. I'm a writer, speaker and a JavaScript developer for AOL (yes, we're still around!).
Thanks for the tutorial. I'd recommend using the hoverFlow plugin to handle the animation queue.
Thanks for the tip! I looked into hoverFlow and it certainly looks like something that would be easy enough to integrate into this example. I’ll try it out.
Thanks for the tip! I looked into hoverFlow and it certainly looks like something that would be easy enough to integrate into this example. I’ll try it out.
Thanks for the tutorial. I'd recommend using the hoverFlow plugin to handle the animation queue.
Pingback: You are now listed on FAQPAL
Pingback: You are now listed on FAQPAL
Nice post. Thanks
No problem at all. I'm glad you enjoyed it.
Nice post. Thanks
Good idea.
Add stop() before initiate the animation. Otherwise when the mouse passes over and then exit the menu several times the animation occurs without need.
Thanks for the tip!. I'll try it out.
Good idea.
Add stop() before initiate the animation. Otherwise when the mouse passes over and then exit the menu several times the animation occurs without need.
Pingback: Fluid Navigation – How to create an informative menu-bar with jQuery & CSS | Design Newz
Pingback: Fluid Navigation – How to create an informative menu-bar with jQuery & CSS | Design Newz
Pingback: dot Blog. The week in links 15/02/10
Pingback: Fluid Navigation – How to create an informative menu-bar with jQuery & CSS « BrightSpark
Pingback: Fluid Navigation – How to create an informative menu-bar with jQuery & CSS « BrightSpark
Pingback: Fluid Navigation – How to create an informative menu-bar with jQuery & CSS « BrightSpark
Pingback: Fluid Navigation – How to create an informative menu-bar with jQuery & CSS « BrightSpark
Pingback: Fluid Navigation – How to create an informative menu-bar with jQuery & CSS « BrightSpark
Wonderful menu. Thank you for the lesson? man.
No problems at all!. I'm glad it was useful.
it's amazing, though i don't know how to write the code, i actually use jQuery on my blog, the theme i chose was designed with it
First of all I’d like to say, great article! I’ve got a little question bothering me, I really love the design of your blog and tried to install the same design on my WP blog. Stil, there is some kind of weird php error in the sidebar. Do you have any tips, which version are you using? Please PM me on Twitter @HealthTipz or per e-mail.
thanks admin…
Pingback: 99 техник создания меню для сайта CSS и jQuery | SHEBEKO.COM
Pingback: jQueryで魅せる動きのテクニック「10 jQuery Transition Effects: Moving Elements with Style」 | WebLab
Awesome menu , transitions beautifully – great tut . Thanx 4 putting it together & sharing it
You’re very welcome! Im glad you found it useful.
Thanks a lot. Very useful indeed
Pingback: [Web] 連結分享 | Geek is a Lift-Style.
Pretty nice. I'm thinking of using something like this but for an Arabic website.
thanks buddy its realy awesome
No problem!
Pingback: iBOX » Blog Archive » Fluid Navigation – How to create an informative menu-bar with jQuery & CSS
superb… thaks a lot dude:)))
No problem at all!
No one have an alternative to slidedeck. I need a javascript similar to kwick whic h allow me to add content to the sliding panels…
Having some bugs when you hover over need to put an stop(true true) ..
Pingback: 16 amazing jquery navigation menu tutorials | ExtraTuts
Nice work but there is queue buildup problem with the menu when all links are hovered upon quickly multiple times.
It is a really different menu. But i don2t think that i would use somethimg in my designs:) But technique is very useful
Pingback: 20 блестящих эффектов на Jquery для вашего сайта
Pingback: » [jQuery]流動的にプルダウンするシンプルなナビゲーションメニューJ-snippet
thats is so simple to implement, will use it from now on
Hi everybody,
I am ameture html css coder. This post really surprised me. Thankiu soooo much~
这个特效真不错 ~
Pingback: Fluid Navigation – How to create an informative menu-bar with jQuery & CSS | Green Ray
Good post , this use for myself , thanks!
Great, implemented to my menu in about 3 minutes
, looks much better now.