Tutorials

Latest Word » Tutorials » Mega Drop Down Menus w/ CSS & jQuery
Mega Drop Down Menu w/ CSS & jQuery

Mega Drop Down Menus w/ CSS & jQuery

Tags: ,

While in the process of redesigning 4wheelparts.com, I decided to explore new methods of working with our huge number of inventory and categories. I did some research and noticed a new trend for ecommerce sites in having what they call “mega drop down menus”.

According to usability expert Jakob Nielson, mega drop down menus tested to be more efficient for large scale websites.I decided to experiment with different ways of implementing this technique and would like to share how I achieved this method.

Given that regular drop-down menus are rife with usability problems, it takes a lot for me to recommend a new form of drop-down. But, as our testing videos show, mega drop-downs overcome the downsides of regular drop-downs. Thus, I can recommend one while warning against the other. – Jakob Nielsen – Alert Box

As I read his article he recommended that these kind of drop down menus should have a subtle time delay when hovering in and out of them. I decided to use the Hover Intent jQuery plugin to help me achieve this effect.

Mega Drop Down Menu - CSS & jQuery

Step 1. Foundation – HTML

Just like all of my navigation tutorials, start by creating an unordered list. Since we will be using CSS Sprites for our navigation states, each link within the list item should have a unique class name to it.

<ul id="topnav">
    <li><a href="#" class="home">Home</a></li>
    <li><a href="#" class="products">Products</a></li>
    <li><a href="#" class="sale">Sale</a></li>
    <li><a href="#" class="community">Community</a></li>
    <li><a href="#" class="store">Store Locator</a></li>
</ul>

Step 2. Styling Foundation – CSS

Since our drop down menu will be using absolute positioning, be sure to add a relative positioning to the list item. Shoot the text off of the page by specifying a text-indent of -9999px. We will then replace each navigation link with an image by specifying an image path to each link class name.

ul#topnav {
	margin: 0; padding: 0;
	float:left;
	width: 100%;
	list-style: none;
	font-size: 1.1em;
}
ul#topnav li {
	float: left;
	margin: 0; padding: 0;
	position: relative; /*--Important--*/
}
ul#topnav li a {
	float: left;
	text-indent: -9999px; /*--Push text off of page--*/
	height: 44px;
}
ul#topnav li:hover a, ul#topnav li a:hover { background-position: left bottom; } /*--Hover State--*/
ul#topnav a.home {
	background: url(nav_home.png) no-repeat;
	width: 78px;
}
ul#topnav a.products {
	background: url(nav_products.png) no-repeat;
	width: 117px;
}
ul#topnav a.sale {
	background: url(nav_sale.png) no-repeat;
	width: 124px;
}
ul#topnav a.community {
	background: url(nav_community.png) no-repeat;
	width: 124px;
}
ul#topnav a.store {
	background: url(nav_store.png) no-repeat;
	width: 141px;
}

Step 3. Creating the Mega Sub Navigation – HTML

Add a class of “sub” right after your main navigation link and nest unordered lists within. Each nested unordered list will act as the nav columns of your mega drop down.
Mega Drop Down Menu


<ul id="topnav">
    <li><a href="#" class="home">Home</a></li>
    <li>
    	<a href="#" class="products">Products</a>
        <div class="sub">
            <ul>
                <li><h2><a href="#">Desktop</a></h2></li>
                <li><a href="#">Navigation Link</a></li>
                <li><a href="#">Navigation Link</a></li>
            </ul>
            <ul>
                <li><h2><a href="#">Laptop</a></h2></li>
                <li><a href="#">Navigation Link</a></li>
                <li><a href="#">Navigation Link</a></li>
            </ul>
            <ul>
                <li><h2><a href="#">Accessories</a></h2></li>
                <li><a href="#">Navigation Link</a></li>
                <li><a href="#">Navigation Link</a></li>
            </ul>
            <ul>
                <li><h2><a href="#">Accessories</a></h2></li>
                <li><a href="#">Navigation Link</a></li>
                <li><a href="#">Navigation Link</a></li>
            </ul>
        </div>
    </li>
    <li><a href="#" class="sale">Sale</a></li>
    <li><a href="#" class="community">Community</a></li>
    <li><a href="#" class="store">Store Locator</a></li>
</ul>

Step 4. Styling Mega Sub Navigation – CSS

To get the sub nav to stick to the bottom left corner of the parent hovered nav, be sure to set an absolute position to the .sub container with the coordinate of top 44px and left 0px. For style, I added rounded corners to those browsers that support it (Firefox/Chrome/Safari).

Keep in mind when having multiple levels of nested lists, you need to override its conflicting properties. Check out the comments below.

ul#topnav li .sub {
	position: absolute; /*--Important--*/
	top: 44px; left: 0;
	z-index: 99999;
	background: #344c00 url(sub_bg.png) repeat-x; /*--Background gradient--*/
	padding: 20px 20px 20px;
	float: left;
	/*--Bottom right rounded corner--*/
	-moz-border-radius-bottomright: 5px;
	-khtml-border-radius-bottomright: 5px;
	-webkit-border-bottom-right-radius: 5px;
	/*--Bottom left rounded corner--*/
	-moz-border-radius-bottomleft: 5px;
	-khtml-border-radius-bottomleft: 5px;
	-webkit-border-bottom-left-radius: 5px;
	display: none; /*--Hidden for those with js turned off--*/
}
ul#topnav li .row { /*--If needed to break out into rows--*/
	clear: both;
	float: left;
	width: 100%;
	margin-bottom: 10px;
}
ul#topnav li .sub ul{
	list-style: none;
	margin: 0; padding: 0;
	width: 150px;
	float: left;
}
ul#topnav .sub ul li {
	width: 100%; /*--Override parent list item--*/
	color: #fff;
}
ul#topnav .sub ul li h2 { /*--Sub nav heading style--*/
	padding: 0;  margin: 0;
	font-size: 1.3em;
	font-weight: normal;
}
ul#topnav .sub ul li h2 a { /*--Sub nav heading link style--*/
	padding: 5px 0;
	background-image: none;
	color: #e8e000;
}
ul#topnav .sub ul li a {
	float: none;
	text-indent: 0; /*--Override text-indent from parent list item--*/
	height: auto; /*--Override height from parent list item--*/
	background: url(navlist_arrow.png) no-repeat 5px 12px;
	padding: 7px 5px 7px 15px;
	display: block;
	text-decoration: none;
	color: #fff;
}
ul#topnav .sub ul li a:hover {
	color: #ddd;
	background-position: 5px 12px ;/*--Override background position--*/
}

Step 5. Setting up jQuery & Hover Intent

For those who are not familiar with jQuery, do check out their site first and get an overview of how it works. I’ve shared a few tricks that I have picked up along the way, you can check those out as well.

Initial Step – Call the jQuery file

You can choose to download the file from the jQuery site, or you can use this one hosted on Google.

<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>

After calling the jQuery file, visit and download the latest Hover Intent jQuery Plugin. Save the file to your current directory, and call the file.

<script type="text/javascript" src="jquery.hoverIntent.minified.js"></script>

Step 6. Launching Code on Document Ready

Directly after the line where you called your jQuery and hover intent file, start a new <script> tag and start your code by using the $(document).ready event. This allows your jQuery code to run the instant the DOM is ready to be manipulated. The code you will be writing in the next few steps will all take place within.

$(document).ready(function() {
	//Code goes here
});

Step 7. Set Hover Over & Hover Out Events – jQuery

Note: When using the hover intent plugin, it requires each hover over and hover out state to be in its own function.

The Logic

When a drop down parent link is hovered over:

  1. Find .sub and fade it in (By default, we will fade the opacity down to 0)
  2. Check if a .row exists (in case you want more than one row in the drop down)
  3. If .row does exists, find the widest row and set the width of the .sub container.
  4. If .row does not exist, set the width of the .sub container.

On hover out:

  1. Find .sub and fade it out (Opacity 0)
  2. Hide .sub (Display none – so it is completely out of the way)

The following script contains comments explaining which jQuery actions are being performed.

//On Hover Over
function megaHoverOver(){
    $(this).find(".sub").stop().fadeTo('fast', 1).show(); //Find sub and fade it in
    (function($) {
        //Function to calculate total width of all ul's
        jQuery.fn.calcSubWidth = function() {
            rowWidth = 0;
            //Calculate row
            $(this).find("ul").each(function() { //for each ul...
                rowWidth += $(this).width(); //Add each ul's width together
            });
        };
    })(jQuery); 

    if ( $(this).find(".row").length > 0 ) { //If row exists...

        var biggestRow = 0;	

        $(this).find(".row").each(function() {	//for each row...
            $(this).calcSubWidth(); //Call function to calculate width of all ul's
            //Find biggest row
            if(rowWidth > biggestRow) {
                biggestRow = rowWidth;
            }
        });

        $(this).find(".sub").css({'width' :biggestRow}); //Set width
        $(this).find(".row:last").css({'margin':'0'});  //Kill last row's margin

    } else { //If row does not exist...

        $(this).calcSubWidth();  //Call function to calculate width of all ul's
        $(this).find(".sub").css({'width' : rowWidth}); //Set Width

    }
}
//On Hover Out
function megaHoverOut(){
  $(this).find(".sub").stop().fadeTo('fast', 0, function() { //Fade to 0 opactiy
      $(this).hide();  //after fading, hide it
  });
}

Step 8. Set Custom Configurations & Trigger Function

Now that we declared the hover over and hover out function in the above step, its now time to set the custom configurations and call the hover intent function.

//Set custom configurations
var config = {
     sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)
     interval: 100, // number = milliseconds for onMouseOver polling interval
     over: megaHoverOver, // function = onMouseOver callback (REQUIRED)
     timeout: 500, // number = milliseconds delay before onMouseOut
     out: megaHoverOut // function = onMouseOut callback (REQUIRED)
};

$("ul#topnav li .sub").css({'opacity':'0'}); //Fade sub nav to 0 opacity on default
$("ul#topnav li").hoverIntent(config); //Trigger Hover intent with custom configurations

For more detailed explanation of how hover intent works, check out their website.

Conclusion

Keep in mind that this script calculates the width of your .sub container (adding up all UL’s per row) and automatically adjusts it. If you would like to specify your own custom width, you can delete that portion of the code and specify a static width in your CSS. This all depends on what you are trying to add in your mega drop down, and each scenario may be different. I hope you grasped the basic concepts of this tutorial so you can make your own custom mega drop down for future projects. If you have any questions, concerns, or suggestions, please let me know!

Mega Drop Down Menu - CSS & jQuery

Inspiration Elsewhere

Now that you know how to create a mega drop down from scratch, check out some of these sites for inspiration.
Mega Drop Menu
Mega Drop Menu
Mega Drop Menu
Mega Drop Menu
Mega Drop Menu
Mega Drop Menu
Mega Drop Menu

Related Articles

Related Posts

Author Bio

My name is Soh Tanaka and I am a Los Angeles based designer/front-end developer specializing in CSS driven web design with an emphasis on usability and search engine optimization. I also run a CSS Gallery which is updated daily with the best CSS websites from around the world. Come check it out!

You can learn more about me or Twitter  Follow me on twitter for more updates and resources!

Did You Enjoy This Post?

subscribe  Subscribe via RSS or by email to get all upcoming tutorials and articles delivered straight to you.

+ Add Comment271 Peeps Have Spoken Their Minds...

  1. Marco

    Looks very slick – well done mate. With CSS3 you could even make “columns” instead of having three different lists. Still, this is a great example which could be used in loads of websites.

    Keep up the great work!

  2. Janko

    Awesome tutorial and really impressive demo. Great work, Soh!

  3. saurabh shah

    nice menu … was looking something like this only and got .. thanks for sharing it !

  4. nana

    Hmm… I cant see the drop down in the demo…only me?
    Using Chrome here..

  5. nomi

    wow …. dude you rock. excellent tutorial. thanks.

  6. James

    Excellent tutorial Soh! Clear and concise and I’ll be using this on future projects

  7. Mauricio Rivera

    Great tutorial! … I’ll keep it in mind if I ever need a fatty menu like this, surely I will.

  8. Robin B.

    Nice solution, thanks ;)

  9. Aaron

    EXACTLY what I was looking for! Thanks, this helps a bunch!

  10. designfollow

    thanks for the great tutorial.

  11. Rocco

    Damn ninjas… :P Nice job, btw.

  12. Jad Limcaco

    Very nice Soh! I have never tried something like this before, and I will definitely refer back to this on my next website that needs a big, fat, overweight dropdown menu. :)

  13. Terry

    Great work! Thanks for sharing.

  14. CIDIC

    what about browser compatibility will it work with anything?

  15. veeru

    It’s really impressive work. Thank you for sharing.

  16. Ackrock

    Love the tutorial, unfortunately i’ve had little success following any tutorials on this issue, i would love (and im sure others would too) if you can do a video tutorial on this subject i’ve searched the web up and down and haven’t found 1 video tutorial on this subject. Thanks Man.

  17. Sean Curtis

    Seems to work ok in most modern browsers (didn’t check IE6) – but why on earth didn’t you make it keyboard accessible? I can’t even tab through the menu at all…

  18. izulcybercafe

    Nice tutorial..

    Thanks…..

  19. Manny

    Well done, this is a great tutorial and IT WORKS GREAT IN IE6! to make round corners in IE6 i’ve had great success with this: http://www.dillerdesign.com/experiment/DD_roundies/ works a treat.

    M [".][",]

  20. Tim Taylor

    I would have a concern about the use of any dropdown menu used in IE6 when it comes to the menu flyout expanding over a select form element. Have you factored in bgiFrame jquery plugin into your code as well?

  21. Pat

    That is exactly what I was looking for. Thanks a lot!

  22. Jauhari

    Excellent and easy to try..

  23. mupet

    Great tutorials, impresive work

  24. James

    Soh, the tutorial is amazing. I was looking for something like that. In future can you make a tutorial on suckerfish menu with animation?

    Thanks

  25. Jacob

    sweet :)

  26. Rilwis

    Good article. I love the way you organize HTML codes. It’s simple and meaningful. I bookmark this for a good reference. Thank you.

  27. Alex Flueras

    Thanks so much! I was looking for weeks for an actual tutorial on MegaMenus. Great article!

  28. michael

    any chance of you making this 508 compliant?

  29. mini

    Very good tutoiral! Can someome tell me for which browsers is used -khtml-border-radius ?

  30. Silverboy

    how much I’ve been looking for something like this…..thanks :D :D

  31. Nadja Design

    Wow those menus are awesome, have been looking for something like this for ages!

  32. Rochelle Dancel

    Oh, wow – thank you for sharing this! Have bookmarked for future use… :)

  33. CMS Themes

    Wow, a great written tutorial mate. I will sure need this drop down menu on upcoming projects.

    Thanks

  34. Five Technology

    This is perfect for a few e-commerce projects we have coming up. Great post. Thanks.

  35. Ali Suarez

    Really useful! Thanks a lot!

  36. Placehold

    Thanks dude, Yet another killer tuts,

    Keep up the great work :)

    Regards

    Craig

  37. Lam Nguyen

    That’s sad when seeing this post in this blog because I planned to write a post about this one. However, I’m very impressed by the awesome tutorial by you. Thanks for your great post :D

  38. Tutorials

    I found your site on a tutorial directory. We recently launched tutorialgrad.com. It’s similar to those other tutorial sites only easier for you. All you have to do is submit your RSS Feed once, we do the rest. We will check your feed for tutorials and post them daily, all with direct links to your site (we don’t frame your content). If you are interested please check it out and let us know what you think.

  39. Gregor

    hey, nicely done!
    But for what do you need do you need the jQuery?
    All that I see in the demo can be done with CSS only these days (as long as you do not need to support IE 6 of course). Even the transitions.

    Good work anyway, and the people love it, you got featured by SM, congrats!

  40. Nick

    Great tutorial! Love the big drop downs…

  41. Rahul - Web Guru

    Very interesting drop down, which is being used quite widely these days in many popular websites too.

  42. theComplex

    Quite awesome, thank you for posting this!

  43. share

    function is possible to “active” in this menu? if so you could give some examples? or answer me please, greetings and thanks.

  44. Matt Propst

    Great article. I’m a huge fan of the tutorial (i’ve bookmarked the page) but was was hesitant of using the concept until i got down to the “real world examples” Ok, i’m sold. Now i just need a project to use the Mega Drop-Down on :-)

    Thanks!
    -Matt

  45. chandrakanta

    Boss. you are great. I am having 2 years of exp. in PHP and I like your tutorial. this is what I need. Cheers . :)

  46. Anne

    Great tutorial, thanks.
    I also liked the green header very much. Wat did you use to make the word “DROPDOWNS”?

  47. montana Flynn

    Excellent timing on this one Soh, a client specifically requested a mega menu!

  48. Hung Bui

    Very nice tutorial and quit useful.
    In my opinion, I would change the hover effect a bit that when hover to other tab the existing mega drop down hide it immediately and show a new one. However, when user move the mouse out of mega dropdown then you can have a subtle time delay.

  49. Anderson

    Fantástico!

  50. Jim

    Thanks for the tutorial! Will be using this in conjunction with a redesign of our business website shortly!

    Cheers! :)

  51. matt

    Great summary! Just in time for our meganav implementation. Kind of crazy how much influence Nielsen has. Seriously though, this would have been a good article even without the resizing portion of the script, but it’s always nice to throw in something a little extra.

    In my laziness I did not realize you could call multiple sets of configurations for hoverIntent. No decent dropdown menu should be without it imo.

  52. George

    Fantastic demo – seems to have stopped working in IE though – might be me, but could someone check? :o)

  53. Mickaël

    Ce blog est décidément une véritable mine d’or !
    Merci pour le tuto !

  54. WPSMASH.COM

    Thank you for this great tutorial!

  55. Nuramon

    Very nice Tutorial!

    Please note, when using the code from this site, the line:
    rowWidth = $(this).width();
    …should increment the widths:
    rowWidth += $(this).width();

    In the demo it’s correct and working. :)

  56. Eric

    Thank you for the great tutoiral and working example! I am trying get the megamenu to display on top of some other elements on my page and having trouble figuring out the z-index levels. Anybody else having issues with the menu being displayed behind other elements on your page.

  57. Gabby

    Nuramon I LOVE YOU!!!
    I have been trying to wrap my brain around what I could have done wrong or where the slight difference could be as my uls were just one big list no matter what I did.
    Next time you’re in Edmonton, Canada I will buy you a drink :)

  58. Soh

    Sorry guys/girls!! That was my bad X-p

    @Nuramon Thanks very much for pointing that out, not sure how that portion got deleted :-p

  59. Rick Dawson

    Thanks for putting this up. It’s just what i’m looking for :)
    The first mega drop down menu that has all features and holds it’s mouse state when over the drop down.
    I found a few tutorials/scripts before which lost the mouseover state when over the drop down.
    I’m trying to get this working for a site that has a fixed width.
    I cannot get the background (body_bg.png) to repeat, if the design has a fixed width (970px)
    http://me.richarddawson.co.uk/menu2

    I’ve even moved the background to it’s own DIV and set the BODY to 970px

  60. Soh

    @Rick, you can just add a overflow: hidden; and you should be good to go~

  61. Alexandre Cruz

    Excellent tuto.

    I´m your follower now. I´ve never see ur blog, excelent, excelent, excelent, excelent !

    continue working in this, i loved

  62. tylerr

    Hi, Soh! Let me say that your Mega Menu is just fantastic!
    There are a few solutions out there, but none with simplicity and effectiveness of Yours…

    I’d like to tweak a bit, but haven’t been able to do so… Wondering if you could help…

    I’d like for the sub-nav to spread to the full-length of the menu, whatever menu option is hovered on… I this case 960px.

    Conceptually, something like this:
    http://www.moosejaw.com

    Thanks in advance, Soh…
    Best Regards, T.

  63. greyk50

    Wow… you can always get cool stuff from Soh’s blog, keep up man, you ROCK!!!!

  64. J DesigN

    I like this menu, thank you

  65. CloneDVD

    Thanks for sharing this wonderful articles. Great jobs!
    I have marked it for future references.
    thanks again.

  66. shab

    Hello, i’m a french guy and i’m congratulate you for this very nice menu.
    However, i’ve a question.
    When i tried to put a background png in sub level to get a transparency, it doesn’t work in IE.
    Because of the function “function megaHoverOver” that make mine sublevel totally opaque.

    Please i need some help!

  67. kels

    Hey Soh what if I didn’t want it to fade in how would I do that?

  68. Can Karpat

    How can i use this menu with only text menu.. Not png?

  69. Jegan

    hey when we use the png fix then we have to use png fix for IE6. is there any other way.

  70. izdelava spletne strani

    Cool, i was just looking around a drop down menu for my new web site and these first one does it. It’s perfect!

  71. Ian Lloyd

    It looks lovely. Nice and semantic … but what happens if I don’t/can’t use my mouse? Erm …

    If you could update the jQuery to make it keyboard accessible – which should be simple enough to do – that would be a really good improvement to it.

  72. Kiran

    Great Navigation, I love it.

  73. kels

    @Can Karpat: Just don’t use the

    text-indent: -9999px;

    and you will be good.

  74. Benji B

    Tested in ie6/7/8 firefox PC/Mac and Safari Mac. Works identically :)

    @kels
    cheers for the tip. Saved me going down the wrong IR path.

  75. Benji B

    oops misunderstood kels post. Disregard last sentence of previous post.

  76. rahman

    great tutorial…
    thanxs a lot..
    good job, its give me inspiration..
    thanx thanx thanx xD

  77. David

    Fantastic tutorial. Anyone having a hard time with the z-index of the menus? They appear behind other objects on my page.

  78. Barry

    Great post. Thanks a lot, for making our life simple. We have started to apply your example in our website.

  79. Erik

    David,

    Having the same problem with the z-index….. Did you figure it out/

    Erik

  80. Erik

    OK, I figured it all out. BUT. How do you reverse the direction of the popup menu when it’s too far to the left? Really stuck on thisone..

    thanks.

    Erik

  81. Moth

    Great mega dropdown! Just used it on a site and it was easy set up.
    Just one issue I’m having:
    When I am on the actual page of the navigation that the dropdown “drops” from it doesnt’ work.
    So if it drops down from my “servieces” link and I am on the services page the dropdown doesn’t show up?
    Any ideas of why? or how I can change this?
    Thanks so much!

  82. D

    Erik, you say you’ve figured out the z-index issue…mind sharing with the rest of us who are stuck on that? :\ Would really appreciate it!

  83. Melissa

    Erik,

    You said you figured out the z-index??? I have been working on it for days with no luck. What did you do? I am using the menu differently than a linear menu it is more like a flyout and it works in everything except IE 6 and 7 what did you do? My example http://www.okaloosagas.com/newsite/working.html.

    Thanks :)

  84. Andrew

    Hey thanks for the great tutorial. Using this in a project that I am working on.

  85. Terje Otto

    I love the mega drop down menus! But :P Can you make a tutorial on how to use it with wordpress?

    In particular with wp_list_pages(); si that I can assign parent pages and grand parent pages so it will mimic the looks of the one you have in demo here.

    REALY hope you can help me on this one! have been working on this for almost two whole days now :P

    Marry Christmas!

  86. Erik

    Hi D, Melissa, and everyone,

    I spoke too soon.. i thought everything was going great until I saw my work in IE6 and IE7…. But We will find a solution. Here is my work so far: http://www.naturalskin.com/home1.htm.

    I wish we could hear from the master…

    Erik

  87. Erik

    Fixed the problem by using a hight z-index for the ul#topnav li .sub. Works fine.

    Erik

  88. Neha

    Great work with easy coding.

  89. Adi

    Hi,

    In IE(all versions) the hover state of each main nav element is disappearing as mouse goes to sub-menu.In mozilla this is goin perfect.
    So after checking in both browsers I think IE is not recognizing the following (hover state) style which is -
    ul#topnav li:hover a{ background-position: left bottom; }

    SO please suggest me the modifications to run this hover state in IE .
    please help…

  90. Melissa

    Hey Erik,

    Just saw your post and jumped back into my code in hopes that would help. Unfortunately my z-index on that ID was alread set to 30000…I think that is pretty high. I am sure it has to do with the way I am trying to use the menu. Since I need it to be positioned over other menu items instead of other content on the page…I may need to go back to the drawing board.

    Thanks :)

  91. marco

    how to make a multilevel menu with this script?
    thansk

  92. mybb

    Thanks…..

  93. Vinidog

    Nice, nice, nice…

    Great job guy!!!

    ;-)

  94. Bucky

    Thanks for the great tutorial! Just wondering, how do I get a semi-transparent PNG dropdown to work in IE? It works fine in Chrome & Firefox but not IE7 and 8.

  95. Schweiz

    Have these implemented and are working great. I’ve got a 950px fixed-width layout and when my browser window is resized to the dimensions of most users, the dropdown on the far right side goes off the page.

    Any way to have this particular menu have the sub-navigation be aligned to the right edge of the wrapper so it stays within the viewable area?

    I’m guessing I can specify a .class for the particular menu and do it? Anyone else have this issue and fix it?

    Cheers!

  96. Betty

    Really great post, thanx! I was looking for a tutorial on mega dropdown menus, and this one seems the most appropriate. I’ll give it a try at once.
    Greetz, Betty

  97. Julia

    Please help, repeated, but “How do I get a semi-transparent PNG dropdown to work in IE? It works fine in Chrome & Firefox but not IE7 and 8.”
    Please help…..

  98. Julia

    One solution for transparent background in ie7, ie8 it’s to add .css(‘filter’, ‘none’)
    will have
    $(this).find(“.sub”).stop().css(‘filter’, ‘none’).fadeTo(‘fast’, 1).show();
    instead of
    $(this).find(“.sub”).stop().fadeTo(‘fast’, 1).show();
    But it cancels out the fadeTo in IE…

  99. Daniel Winnard

    Hi,

    This is a great tutorial, one which I have implemented into our site. One question though for you CSS savvy guys. What would I have to do to get the sub part to appear above divs after the navigation? Is this a Z-index job?

  100. Matt

    Anyone having any trouble with IE not formatting the UL’s into two columns in the menu? That’s what’s happening on mine. You can see an example of it here: http://www.gallsdirect.com/gwebc/menus/menu2/menu2.html

    (P.S. Only the first item in the menu is actually ‘linked’ – the rest is a flat graphic. It’s just for testing purposes at this point.)

  101. tylerr

    In need of a small fix: How to make the mene NOT fade, but simply show/hide?

    To clarify, how to “remove” fadeTo from the following code:

    function megaHoverOver(){
    $(this).find(“.sub”).stop().fadeTo(’0′, 1).show();
    ————-
    function megaHoverOut(){
    $(this).find(“.sub”).stop().fadeTo(’0′, 0, function() {
    $(this).hide();
    });

    Soh, can you support a bit?

    Thanks in advance to all!
    T.

  102. Irene

    Wow, Great!

  103. Stefan

    Erik,

    Did you already figured out how to reverse the direction of the popup menu when it’s too far to the left?

    Thanks!
    Stefan

  104. Jamshed

    It is awesome dude!

    i was waiting for this for long time

    thnx.

  105. Dean Perry

    Another inspiration site could be http://tv.adobe.com

  106. Áki

    thanks man, awesome

  107. Áki

    @tylerr:

    this works for me:

    function megaHoverOut(){
    $(this).find(“.sub”).hide();
    }

  108. Aravind

    It’s so nice…..thanks….

  109. Matt

    Stefan, Erik – I’m also trying to figure out the problem of having the menu float out too far to the left. I’ll post solution here if I figure it out, and hopefully you can do the same. Or maybe someone can assist us with this? I’ll say this – simply adding a CSS class (like .subleft) isn’t enough since the script depends on that class being called ‘sub’ and it will break the functionality on your menu if you re-name it. I suspect I will have to add elements to the script as well to fix this. I will begin experimenting.

  110. Stacy

    Great! Thankyou!

  111. All Web Services

    What a nice menu and a great tutorial, this is what the big online shops use.

  112. Greg K

    Can you please show us how to make the “active state” work in this tutorial? I’ve read your other article and can’t seem to combine the two to work together. Any thoughts?

  113. Steve

    Absolutely fantastic script, fine work! I’ve used and adapted the script here … http://www.uprint.me.uk – one of the best Jquery scripts i’ve used. Thanks for all your effort.

  114. Ahmad Ali

    mmhh nice but why when i mix with Mootools its wont work ??

  115. Ayman Aboulnasr

    Great work, thanks alot for sharing.
    By the way, Christian Watson of http://www.smileycat.com has gathered 29 examples worth seeing Mega Drop Down Menus here:

    http://www.smileycat.com/design_elements/mega_dropdown_menus/

  116. Roelof Wobben

    Hello,

    I try to make this work on this test site. But it don’t work.
    Can you help me where things are going wrong here ?

    Roelof Wobben

  117. Russ

    Great Work!!

    I think you have done well to make this look nice..However, I have to say I am not too keen on how the menu fades.

    I think it should completely disappear before showing the next menu as otherwise it serves as a distraction.

    But that is just the first impression I got of it.

    Definitely very nice though!

    Good work..

  118. Steve

    Russ > You can alter the speed at which the transition happens to make it much faster or no transition at all. A great script all told.

  119. James

    Nice script, but I have a little problem that when I hover over the menu the drop down seems to make the whole part move to the left ?

  120. Dirk

    @Erik,

    You made me happy. The z-index in ul#topnav li .sub works pretty fine.

  121. DesignerSandbox

    Let me try to get this into my next free joomla template.
    Nice tutorial

  122. Betty

    Trying to integrate this great mega drop down menu into a cms, with automatic pages in collumns, but so far with no succes. The dropdown menu itself is working great though! Thanks, Betty

  123. @JBertling

    This is a really great, easy to follow tutorial.

    Used it myself and it turned out brilliantly. I will definitely recommend this to other looking to achieve this effect.

    One small, nitpicky, css thing… you don’t need the ul in ul#topnav. The id is unique by definition.

    Great Job! Cheers!

  124. Derek

    Anyway to do this vertical?

  125. Jesse

    I solved the IE z-index issue by setting the parent element to position relative with a z-index lower than the nav.

    .container { position: relative; z-index: 1; }

  126. Andy

    I’m ready to go with this menu except it’s always aligning to the right of the active item, even if it’s off the page. How do we make it so it either goes the other direction at half-way: http://www.johnlewis.com or it moves so has enough room: http://www.gooutdoors.co.uk

    Any ideas anyone?

  127. Vault256

    Great menu, thanks for posting it.

  128. Daniel

    Very nice post! Still trying to understand hover intent in deep, but I’ll get that! :)
    Thank you!

  129. Josh

    I’m having the same problem with IE not breaking at the spot as well, anyone figure this out?

  130. Alessandro

    I can’t make it work. I used the exact same code. Just changed a bit the images, to test everything. But nothing. No result. It just doesn’t work. See for yourself: http://www.soulforrent.it.

    Dammit…

  131. rich

    Great menu! Does anyone know if it’s possible to edit this to open onclick rather than on hover, and to close using a X button within the popup window?

  132. bercini

    there is similar drop down menu below. I wonder which one works better?
    http://www.skyrocketlabs.com/articles/jdiv-a-jquery-navigation-menu-alternative.php

  133. Harry

    Hey man, been looking for a decent mega menu tutorial for ages! One question: I’ve used the theory above to make a mega menu but to add to it I’ve anmated the button li so when you hover over it, the menu appears but also the li text moves up & the background becomes less transparent.
    I’ve got it working perfectly in Ie7+, FF & Safari, but for some bizarre reason it won’t work in Chrome, mac or pc :-(

    Would it be possible to send the snippets of code to see if you would know why its not working? Chromes always been the yardstick for me but I’m totally confused how its the only browser with a problem. I’ve narrowed it down to the extra animations (without them the menu works fine) but from there I am stumped. Any help would really be appreciated,

    thanks again

    Harry

  134. Harry

    Hi again,
    I discovered the problem was with a Twitter feed at the bottom of the page. Why this was causing a problem I really don’t know, it was the default code from the twitter website, but when I took the div for it out, the menu worked perfectly in Chrome :-/ sorry to bother you, am going to go a sit in a confused lump in the corner

    cheers!

  135. Rachael

    Hei!

    I just made some good progress implementing this in a client website.. however Im trying to divide sections by a border-right….. and I came with this:

    between every section I add this

    This of course doesn’t work with IE7…and that doesn’t really mean something to me , eventually people will stop using IE7 . (like in 10 or 15 years)

    I want to do something like the PUMA site… http://www.shop.puma.com/on/demandware.store/Sites-Puma-US-Site/en/Home-Show?source=marketing

    But my lack of knowledge in Jquery or css, is making me crazy!

    Someone know how to simplify this tutorial for dummies :( :)) …

    Lot of love!

    Rissy

  136. Angelis

    Yo yo..

    I have one to make .tpl file from this briliant menu in php. Anybody help me how i do this? How i can make .tpl file?

    Thanks,
    Angelis

  137. david

    Thank you for this! You make it so easy to implement.

  138. sain

    Nice and awesome work
    Thanks for sharing

  139. Jenniffer

    Gracias!!!!!!

  140. Vicky

    I would discourage text-indent to the out of screen. It’s dangerous for SEO.

  141. Park

    Great tutorial – thank you very much. This should keep me busy for a while coming up with one of these beauties for my site.

  142. Richard

    What a fantastic tutorial, thanks!

  143. Infrared

    Great tutorial, many thanks for this. I’d like to add a drop shadow to the .sub menu but so far my atempts on getting this to wor have been a tad futile. Tried adding a .menuShadow class to the sub menu with a background image but it gets cut off at the edge of the menu so you don’t see it bleed out. Anyone any ideas on how i could get this to work?

  144. CSV

    Absolutely nothing beats hand coding – it sort of reminds me of the old days of shooting a film camera in manual as opposed to using a digital camera in total automatic (a cms system). Thanks for the share.

  145. Actionspat

    Nice tutorial, i adapt the script to be vertical, works fine… except… in IE6 (30% of visitors of the site i work on are on IE6…) where the div .sub is under the ul#topnav li . i feel frustrated !
    thanks anyway

  146. Jeremy Crane

    Question for anyone that’s listening. I’m using Chrome and the demo works beautifully, but when I copy the entire source code of the demo save it as it’s own HTML file and try it, the drop down doesn’t work. Does anyone have any idea why this would be? Thanks.

  147. sangheethan

    Hey nice tutorial man.. but I have a jquery carousel and was trying to put this mega menu as well… both dont go together?

    I dont know why.. If I take off the carousel the megamenu is working and vice versa…

    Please advice me on this…

  148. Tofudisan

    This is a FANTASTIC how-to! This singular article proved to be the main kickoff to getting my interested in jQuery. Now I’m hooked on it as my preferred framework.

    I’ve started an eCommerce site for my employer and I’ve used your mega-menu as my template. It works beautifully except for one issue. I’ve noticed that the right-most menu can overlap the edge of my 960 layout. On resolutions less than 1280 this causes problems even though the design fits a 1024 screen as the menu slides off screen and you literally can’t get to it.

    I’m currently trying to figure out how I can detect the edge of the chrome area so I can have the jQuery slide the menu left/right depending on the need. Being new to jQuery (and even javascript in general to be honest) I’m a bit stuck as to what to do. But I’ll toil on and hopefully come up with a elegant solution to share with you.

    Thanks again for posting this! It’s literally changed my coding life! :D

  149. Tofudisan

    Hmmm…. I posted my solution yesterday but I see it didn’t show. Could be the embedded code?

    At any rate what I did was:

    1. used $(this) in the megaHoverOver() to get the sub menu.
    2. Checked the sub menu’s left property and added that to the rowWidth variable to calculate where the right edge of the sub would fall pixel-wise
    3. Checked the right edge pixel value against document.documentElement.clientWidth to see if the right edge falls outside the visible area of the browser window.
    4. If the right edge will flow off screen then I calculate a new left edge value to be document.documentElement.clientWidth minus the right edge value. I also subtracted 40 px to account for a vertical scrollbar if needed.
    5. Set the sub menu’s left edge via $(this).find(“.sub”).css({‘left’:newLeft});

    This works for my instance. You could substitute a wrapper’s boundary for document.documentElement.clientWidth to constrain the menu to the wrapper instead of the view port of the browser.

    Happy coding!

  150. GKiller

    Awesome tutorial and demo. Of course, IE7 has to rear it’s ugly head and refuse to allow the hovers to work.

    I tweaked the z-index values for the ‘.container’ and ‘ul#topnav li .sub’, but to no avail.

    Any suggestions on how to get this to work in IE7?

    Thanks

  151. GKiller

    Well, I guess you can disregard my last post. Turns out that our “IT” dept ran an update for IE7 causing scripting to be disabled. I didn’t realize it until I tried viewing one of my sites that used various scripts.

    Once I reset all Security zones back to default settings everything worked.

  152. Ouzodestructo

    Great Menu! I’m looking for a cool menu like this that sits at the bottom of the page and drops up. Can I do that with this? If so, how is it done?

  153. skip

    I am a newbie to this, where in the code do I paste the code in Step #2?

  154. steve c.

    Hi Soh – Great script! I was just wondering if there is some kind of fallback if the viewer doesn’t have javascript turned on?

  155. 天朝P民

    非常不错,天朝P民路过,顶!very good!

  156. BJ

    Where the .png files at? please help

  157. Aneef

    hi im getting the following error ??

    Message: Object doesn’t support this property or method
    Line: 77
    Char: 25

    URI: http://www.catalogues4u.com.au/Calendar.aspx

    how do i solve it ? please help

    $(“ul#topnav li”).hoverIntent(config);

  158. Kevin

    Great script – got it working in no time at all. One issue though – I include the Prototype 1.6.1 and scriptaculous 1.8.2 libraries for another function. Since adding this MegaMenu the other function fails.

    If I remove the reference to jquery.min.js 1.3 then the other function works – is there a known clash of variables or functions? Is there a way around it?

    Includes these (before jquery.min), and your menu fails:

  159. Kevin

    Solved, I found this:

    http://docs.jquery.com/Using_jQuery_with_Other_Libraries

    …so moved the JQuery references ot the top of the Section, followed by the document.ready function. Just before this function I added the…

    jQuery.noConflict();

    …line and renamed all…

    $(

    …to…

    jQuery(

    …and both functions worked!

  160. Wilmer

    Hey! This is a very nice drop down menu. However I have a problem I can’t solve. Everything works perfect when I work off line, but after I upload the files it fails. The paths are checked and correct.

    http://www.travelnetherlands.net/test/

    Help would be appreciated very much!

  161. Wilmer

    Just after this comment I found out it had something to do with the CHMOD permissions of one the scripts. I don’t know how it happened, but I’m glad it’s solved.

    Thanks for this piece of code!

  162. Sami

    Help!

    I´m trying to do as above mentioned, but my knowledge in programming is obviously not good enough. :(

    Can someone help me with how to put the code so that I can enjoy this wonderful drop down menu, please.

    Thanks!

  163. Daniel

    great menu!! works a treat

  164. dan

    sorry one other thing if i wanted the submenu items to be listed horizontal in a line how do i go about it ?? tired a couple of things but still vertical

  165. asgar

    Rounded edges is not working in ie8 adn ie7, pls help me

  166. Mags

    Has the Z-index problem been cleared up once and for all as I’m having similar problems with elements being in front of the mega menu?

  167. Derek S.

    Nice!!! Just what I needed to learn! I am going to do this for WordPress, and found someone that tweaked this tut for such at http://erikt.tumblr.com/post/277013774/mega-drop-down-menus-in-wordpress

    Thanks again!
    Derek

  168. Soh

    Very cool! Thanks for sharing Derek!

  169. Kenny

    I’ve resolved the problem I was having with the sub menu not displaying properly in IE6 and IE7 – the high z-index must be added to the ul#topnav li class:

    ul#topnav li {
    float: left;
    margin: 0; padding: 0;
    position: relative; /*–Important–*/
    z-index: 99999;
    }

    See ‘Step 2. Styling Foundation – CSS’ above. I didn’t have to assign any z-index to any container elements, and Erik’s fix (of applying the high z-index to the ul#topnav li .sub class) wasn’t enough in this case.

    Worth re-mentioning I think that multi-columns don’t display on IE6.

  170. Maximusweb

    @ Kenny

    THX for this fix :)

  171. kad1r

    Thank you very much. I needed to make new css menu :)

  172. Jessica

    Hello,
    Do you know how to make a mega drop down menu in Magento (ecommerce)

  173. snell

    Everything working good but hover not working…

    Great tutorial.

    Thank you very much.

  174. Eric

    @Soh Tanaka – love this menu. Thanks so much for sharing :)

    @Kenny – _thank you_ for the IE note. You’re a life-saver. Your note couldn’t have come at a better time. I was wondering how to get the menu to show in IE.

  175. harikaa

    Thank you.it is very good:) good morning;)

  176. Avangelist

    So many comments! But I got a sensible question.

    Why use the plugin over the .hover() function within jQuery? What does the plugin provide that makes it better?

  177. Sam

    Beginner here…how do you slide the menu left/right depending on the need? I noticed all the websites linked here do it, but sohtanaka’s example doesn’t do it. Thank you

  178. Sam

    Same guy here, found a solution “You will need a separate class or id for each one you want to move inwards and you will just have to play around with the right property until you get the correct position.”

    I just created a new “sub” class for the last element, using the same style for .sub
    ul#topnav li .sub {
    position: absolute;
    top: 44px; left:0px; <– change "left" to "right"

    Also need to add this new sub class to the javascript functions.

  179. Giuliano

    Hi Julia, I tried your suggestion to include:
    $(this).find(“.sub”).stop().css(‘filter’, ‘none’).fadeTo(‘fast’, 1).show();
    instead of:
    $(this).find(“.sub”).stop().fadeTo(‘fast’, 1).show();
    but it doesn’t show transparence on the sub menus in either IE nor FF.

    If I try the following class in the main div container only workf in FF but not IE:
    .transparente
    {
    -ms-filter:”progid:DXImageTransform.Microsoft.Alpha(Opacity=80)”;
    filter: alpha(opacity=80);
    -khtml-opacity: 0.80;
    -moz-opacity: 0.80;
    opacity: 0.80;
    }

    Please advise.

    Thank you

  180. Angela Frrench

    I love these menus, but fear for all the people who can’t access them because they rely on the use of a mouse.

  181. Iris

    @Soh Tanaka
    Thanx for the menu

    @ everyone that also had trouble with z-index in IE…
    Found an elegant solution here: http://www.vancelucas.com/blog/fixing-ie7-z-index-issues-with-jquery/
    Works good in both IE6 and IE7.

  182. Dave

    Hey,

    Been working with this for a few hours and I have 2 problems, both have been asked by previous commenter but neither has been answered.

    1. Instantaneous show/hide with no fade. I can set the fade to 0 milliseconds, but there is still a delay. I managed to get the onMouseOut to work with the code supplied by AKI in the comments, but the mouse over/show there is still a slight delay. I am sure this is because of the use of fadeTo but I don’t know JS enough to take it out without breaking the function.

    2. In IE when i mouse away from the original button and into the submenu, the original button loses its hoverstate. Someone mentioned this but wasnt answered. It works in all other browsers.

    Any help would be awesome.

  183. Dave

    Ok just fixed problem #1 from my last post, heres my fix if anyone else needs it:

    Instant sow/hide with no fade:

    First, in the css change the parameter that gives “display: none;” to visibility: hidden;,

    then replace the JS with something along the lines of this:

    $(function(){

    var config = {
    sensitivity: 7, // number = sensitivity threshold (must be 1 or higher)
    interval: 1, // number = milliseconds for onMouseOver polling interval
    over: dropOpen, // function = onMouseOver callback (REQUIRED)
    timeout: 1, // number = milliseconds delay before onMouseOut
    out: dropClose // function = onMouseOut callback (REQUIRED)
    };

    function dropOpen() {
    $(this).addClass(“hover”);
    $(‘.sub’,this).css(‘visibility’, ‘visible’);
    }

    function dropClose() {
    $(this).removeClass(“hover”);
    $(‘.sub’,this).css(‘visibility’, ‘hidden’);
    }

    $(“ul#topnav li”).hoverIntent(config);

    });

    Hope it works for you, still need help with the IE problem, if I fix it I will post the solution here.

  184. Dave

    OK, I fixed problem #2, and man… could it be anymore annoying?

    Losing hover state of topnav in IE.

    Solution:

    upload your code to a server. For some reason the browser preview/local display of the site wouldn’t let this work. I uploaded it to get some help, and as soon as I did so I noticed it worked. With identical code, the one online worked.

    If anyone can tell me why this would be the case… please let me know I feel inept having things “just work”… I want to know why.

    Thanks

    D

  185. Avangelist

    I have been able to implement this, although I am not using the additional animate plugin.

    What I am experiencing is menu blocks which contain more than 1 UL are display a flash of height on first click before setting the width.

    I figure this is because the UL’s are floated, but don’t get floated until the width has been calculated. So on first click when the div gets set to display:block, they’re still ontop of each other.
    Is there any way to remove this issue but retain a default width in the CSS?

  186. Kumar

    hey that’s great website……..

  187. Kent

    very good, I’m finding this.

  188. Adam

    This is really awesome – I hope someone can help me – I have a drop down on my far right hand site of the navigation – the drop down therefore falls down outside of the viewable screen area – is there anyway of making the drop down on the right align left / detect the browser/ screen width?

    I hope someone can help,

    Thanks,

    Adam

  189. Frederick

    Great tut, THx for the ideas.

  190. Jayson Bars

    Hello There! This is a great tutorial that make use of hoverIntent and jQuery. However, i had a problem encountered. The menu looks fine when i roll over my mouse but whenever there is an image or images right under the menu, the div (class = “sub”) appeared under the image.

    I already checked the z-index to make sure. Still, it’s not working. Could you help me? Thanks!

    Best regards to you!

  191. Jayson Bars

    by the way.. the problem only appeared in IE. it’s me again – Jayson

  192. Daniel

    Thanks dude! Nice work.

  193. ToSh

    Hey Adam Im trying to find a fix for this too…

    I have a drop down on my far right hand site of the navigation – the drop down therefore falls down outside of the viewable screen area – is there anyway of making the drop down on the right align left / detect the browser/ screen width?

    I hope someone can help,

  194. Murtiano

    Thank you for the tutorial. But I have problem with changing it to vertical menu. It works on hover but when sub opens other menus sliding down at exact height of the sub.

    Shortly, im trying to make it like at http://www.hepsiburada.com at leftside main menu that opens with a contents.

    Please help me!

  195. Tyson Swing

    Dude, your mega menu is like a 60 hit mega combo on Killer Instinct. Nice, clean, elegant, etc. and kicks a**. Thanks for the tips and tricks for the non-graphically talented.

  196. datshay

    Rock n rolll

  197. Harry

    Awesome tut, just having a bit of a weird time with IE8, I’ve got the megamenu working a treat, within the dropdown are some css rollover icons, but in IE8 when you roll over the menu, the pngs in the dropdown are completely transparent revealing the div underneath the menu. When you rollover the pngs they correctly hover to another png and are fine from there, it’s just before you roll over them they seem to leave big holes in the menu, I can’t find anything about this anywhere and it’s doing my nut in!! Just wondered if you’ve ever seen anything like it?

  198. Atlante

    So I wanted to follow the tutorial for the wordpress integration as you can find here: http://erikt.tumblr.com/post/277013774/mega-drop-down-menus-in-wordpress. Well I’m not a coder and I’m lost, any help will be truly appreciated. I did followed your tutorial and created the static menu, then I created the functions as described in the tutorial by erik teichmann, but the last part of his tutorial has me scratching my head and pulling my hair out. How and where do I paste the “function call” is it supposed to be enclosed in php tags? or inside the div tag? Again any help will be truly appreciated!!!

  199. Kevin

    I want to use this menu system for the redesign of a University web site, but since it is a state university, it has to be section 508 compliant. Has anyone found a good way to make these mega dropdowns accessible via keyboard?

  200. Mark

    Amazing work! Thank you.

  201. AL

    Great menu!!!

    I was curious to know if there is a solution for the menu to display properly in Chrome and Safari?

  202. AL

    Looks like an issue on my end… your menu appears correct in Chrome and Safari.

    My bad!

  203. Neil

    Nice example. Probably the best looking example mega menu I’ve seen in a tutorial. It would have been more helpful if you included the source files for download. At the very least, the background images would be useful since the code in the tutorial displays absolutely nothing without them.

    May I make a few observations?

    You header div is wider than the container div it’s nested in. If the container div is set to overflow: auto, which is common with floated layouts, it will make a horizontal scroll bar. Also, setting the text-indent to -9999 is a dirty hack. I would have wrapped the text to be concealed in a span tag and done something like this: ul li a span{ display: none;}

    As i said earlier, it is a very good example. You have my admiration.

  204. bob

    @ kenny

    setting the z-index/position relative to the nav container worked a treat. My page has all sorts of random floats / absolute positioning going on due to content sliders etc. Was doing my head in trying to get the drop down to float above them all.

    I is one happy geek :-)

  205. Kapil

    Firstly thanks for a wonderful Menu tutorial,
    and for you all guys who had the z-index issue …
    here’s the simplest solution :
    add z-index: 99999 in css class ” ul#topnav li “

  206. Richard

    Excellent Tutorial,
    Does anyone know which part of the code keeps the primary item pressed down when you hover over the sub container. With my menu, the main menu buton only hovers when the mouse is directly over it. Any help would be gladly appreciated!
    Thanks – Rich

  207. Evan Skuthorpe web designer

    very nice indeed. great tutorial!

  208. Truco

    Very nice it was, I will try to implement on my blog. Thank you.

  209. Simon Brown

    This megamenu stuff is all very well but there still isn’t one that is completely compatible with WordPress. WordPress 3 has a menus feature that enables people to create menus in a semi-dynamic way (very wysiwyg but doesn’t update when wordpress categories change, how very wordpress :S)

    Problem with megamenu is you need to have divs within the list, and WordPress3 menus don’t support this.

    I have ended up creating a new Walker called PT_Nav_Menu – basically a copy of the default Walker (Walker_Nav_Menu) – but with a change to the start_lvl and end_lvl functions. Ideally I wanted to extend the Walker_Nav_Menu but that didn’t work for some reason, might go back and see if I can make it happen because it would be way more elegant.

    Anyway, using the clone of the Walker_Nav_Menu class, I make make start_lvl and end_lvl draw in DIV or /DIV every other time it draws in a UL or /UL.

    Then in my template where I instantiate the menus I do this:

    ‘menu-header’, ‘theme_location’ => ‘main’, ‘menu’ => ‘mainmenu’, ‘walker’ => $newWalker ) ); ?>

    So far it’s spitting out the right HTML, now I just need to apply the correct style and jquery and I’m all there.

    (sigh)

  210. Simon Brown

    didn’t work.

    Source code came out looking fine.
    set up the styles and the jquery stuff and for some reason, no joy. No js errors, no errors on the server, no major validation errors on the css or JS, just not working. No time to deal with it now, will have to find a working solution or give up. Yet another WordPress blind alley.

    For a system that is supposedly well supported, WordPress is a horror when things aren’t going as you want them to.

  211. Luke

    Hey, I have tried to use this, but where are the image files for download? Thanks

  212. Anandu

    Hey its nice dropdown menu, but if i had a select box just below the menu, dropdown goes behind the select box in ie6. cud u send me the solution

  213. Andrew

    What’s the name of the font used for the menu example? ie. the font used for “home”, “products”, “sales items”, etc.

    Thanks.

  214. Diego

    Great tut!!

    Diego

  215. Anton

    Nice, Thanks man..

  216. John

    Cheers, used some of the code on this site http://www.outdoorenthusiasts.co.uk/, works really well

  217. DECHAMBOUX

    sorry, but I can not get the transparency effect on the buttons …?

    I am French and the translations are not easy.

  218. Carter Baker

    Hey, I have white dots on all of the different menu elements. When you move your mouse over it, it disappears. JW if there was something I did that would cause that.

  219. Carter Baker

    I forgot to include my URL, http://iphather.com/new/

  220. DECHAMBOUX

    I tried, but without result, I can not get the transparency effect rounded tab-through …

    I certainly do not understand !!!!!!!

    Bad!

  221. DECHAMBOUX

    J’ai enfin compris…!!! TOUT est dans le “BOUTON” il me reste plus qu’à le faire correctement….

    Vous devriez le mettre en téléchargement également pour une meilleure compréhension des “novices comme moi…

    mais BRAVO pour la rédaction de ce MENU, il va être très utile pour tout le monde…

    Encore bravo et mille fois merci !!!!!
    ________________________________________________________________

    I finally understood …!!! EVERYTHING is in the “BUTTON” it remains for me to do it correctly ….

    You should also download the set for a better understanding of a novice like me …

    but Bravo for writing this menu, it will be very useful for everyone …

    Again, congratulations and thank you a thousand times !!!!!

  222. Tayfun DEGER

    Nice:)Great post..

  223. DECHAMBOUX

    Voici mon adaptation et un GRAND MERCI à SOH TANAKA !!!!!!!!!!!!

    Here’s my adaptation and a BIG THANK YOU to SOH TANAKA !!!!!!!!!!

    Voici les boutons à créer et images à créer !

    Here are the buttons to create and image to create!

    CONGRETULATIONS SOH TANAKA !!

  224. jeffery

    AHHH ……. THE GREAT WEBWONDERS UNFOLDING!!!!

    THANKZ VERY MUCH FOR POSTING SUCH A NICE CLEAN AND NEAT ARTICLE!!!

    YOU REALLY DONT KNOW HOW MUCH THIS ARTICLE HAVE HELPED ME IN MY WORK….

    :-)

  225. Danny

    Great tutorial! I’m trying to get it to work along with Prototype/Scriptalicious/Lightwindow. Any thoughts on making it happen?

    I have a test page set up here:
    http://www.paul-rand.com/index.php/site/books_thoughtsOnDesign/

    Thanks so much!
    Danny

  226. Steven

    This question came up a few times; How to get the dropdown on the far right of the #topnav to fall down aligned to the left? Now the dropdown will always fall to the right. So the dropdown menu will fall outside the screen.
    Has anyone found a solution for this yet?

  227. radiii

    Hello Soh I used your tutorial,great tutorial, but I seem to be having issues with it. In Internet Explorer 6 the last link not showing up, and the first link is already active when you roll over it. Is there a fix?

  228. Rosette

    Hi Steven, I’m doing something similar. To get mine to line up so that the menu items on the right have dropdowns that fall to the left, I specified a negative margin-left for each line item but also had to create separate id’s for the items that I wanted to have a negative margin.

    So I had essentially something like this in my css:

    ul#topnav li#nav-about {
    margin-left: -200px;
    }

    etc….

    Soh, I had a question though, my font doesn’t look right when the hover occurs. If I turn off the javascript, it looks fine, but when it’s on, not good….I’ve tried cleartype fixes and such but can’t figure out what is wrong. Nothing is working. My dropdown portion of the nav uses an outer wrapper (to hold left shadow), inner wrapper (to hold the right shadow) and another wrapper to hold the dropdown hover menus (had to do it this way because my png graphic on the inner wrapper kept showing a black border where the transparency was). Any ideas? Thanks and I love your tutorials!

  229. Rafael Fideles

    Awesome tutorial, thanks! I was also having problems with the drop down extending too far left and i found a simple solution. On the div with the SUB class i added a margin left style with a negative number.
    Ex.:

    i am not a programmer, so i don’t know if that’s the CORRECT way of solving the problem, but it worked for me.

  230. David

    Nice Menu. I’m in process of implementing it on a couple of sites now. Big fan of jquery lately, except I tried to use a lightbox and ran into that whole thing. Not a big deal, but kind of a pain!

  231. lucas

    Hi, very nice, i really like this tutorial !, i have added to my personal list in spanish and english
    http://www.ajaxshake.com
    thanks

  232. Halif Saban

    Man, I love your menu.. I’ve using it for almost all the projects I’ve been working on..

  233. Steven

    Hi Rosette, I don’t quite get what you mean. Do you have a ‘bigger’ example for me?

  234. Steven

    This works fine in all browsers. I assigned another class to de .sub. It is not the best solution I guess. I hope someone figures out how to get this done with JS.

    ul#topnav li .sub-droptoleft
    {
    margin-left: -350px;
    }

  235. Steven

    Soh, please add this to the previous post: <div class="sub sub-evenementen">
    Thanks!

  236. Steven

    Oops. This is the right one:

    <div class="sub sub-droptoleft">

  237. Brit

    To fix the floating off the right side I replaced:

    $(this).find(“.sub”).css({‘width’ : rowWidth});

    with

    var o = $(this).find(‘.sub’).offset();
    var p = $(‘#PAGE_DIV_ID’).offset();
    var pw = document.getElementById(‘PAGE_DIV_ID’).clientWidth;
    var tw = rowWidth;
    o.left = o.left – p.left;
    var tml = (tw + o.left) – pw;

    $(this).find(“.sub”).css({‘width’ : rowWidth}).css({‘margin-left’:'-’ + tml – 49 + ‘px’});

    You will need to put the ID of your main div that has the page width where it says “PAGE_DIV_ID”. I added in the extra -49px to the tml because the calculations were just a little off.

    Example: http://docreativedesign.com/zencart/pet_care/

    If you see the first link full of gibberish just ignore it, I put it in as filler to push the menu far enough to hit the right side of the page. This has been test in Chrome, Firefox, and IE8.

  238. Brit

    I forgot to also include this in my last post. I had to add this into the megaHoverOut function right above the hide function. This resets the div back to a margin of zero after hovering off of it. If not it tries to use the offset value with its new position when hovering over it for a second time:

    $(this).css({‘margin-left’:’0′});

  239. AC

    Great code.

    I can’t seem to get this to work with multiple divs, i.e., it only works on the first div containing .sub, so any additional div containing .sub does not work.

    I have a main menu, then I have a search menu in another div and I need this to also work in my search menu div.

    Thanks and nice tut!

  240. AC

    Also, to everyone who is trying to get their dropdown to fall to the left, all you have to do is simply specify the right attribute on any div containing the sub class where you need it to open to the left.
    <div class="sub" style="right: 0px;">

    This way you can have your menus on the left side open to the right and your right side menus open to the left, keeping everything on the screen (like foodnetwork.com).

  241. Gary Aure

    I cannot get it working well on IE. Menu shows underneath the elements with style:

    position: relative

    //I’ve tried to add:
    z-index: 99999;
    //on
    ul#topnav li { }
    //but it doesn’t solve the issue

  242. umit olmez

    Thanks, to this information help me a lot of work

  243. Deepjyoti

    Can we get hold of the source code for each file……HTML, CSS, JS, jQuery…….to test it out within our systems……….including the image files………..I’ve tried to work it out following the code given in the tutorial……….so far it does not seem to work, I must be missing something………..Great effort though………..really appreciate the generosity……….Thanks a lot!!

  244. isa ayranci

    great a post. great a information. Thank you.

  245. nick

    Great tutorial , but i would be really greatful if you could pass us the images so we could understand the tutorial in a better way and we gain a benifit from it

  246. Brit

    Reply to GARY AURE. I had the some concern happening on my site. After I had fixed the z-index to be the highest value on the site it still made the menu float underneath the other elements on the page. I had to put a z-index on the relative container of the menu higher than the z-index of the menu. That seemed to fix the problem with IE.

    My 2 styles ended up reading and you can view the menu at http://docreativedesign.com/zencart/pet_care/:

    ul#topnav li {
    float: left;
    margin: 0; padding: 0;
    position: relative;
    z-index:12000 !important;
    }

    ul#topnav li .sub {
    position: absolute;
    top: 26px; left: 0;
    background: #ccc;
    padding: 10px 20px 20px;
    float: left;
    /*–Bottom right rounded corner–*/
    -moz-border-radius-bottomright: 5px;
    -khtml-border-radius-bottomright: 5px;
    -webkit-border-bottom-right-radius: 5px;
    /*–Bottom left rounded corner–*/
    -moz-border-radius-bottomleft: 5px;
    -khtml-border-radius-bottomleft: 5px;
    -webkit-border-bottom-left-radius: 5px;
    z-index:10000 !important;
    }

  247. André

    Hi!

    I’m currently trying to implement this mega menu into my WordPress, but I’m having som issues as to where the different parts of the code should be entered, and how to get it to work.

    My header.php currently starts like this:

    It would really be magnificant with this meny integrated with WordPress so any help with clearifying this would be widely appreciated!! :)

    Thanks for an outstanding tutorial!

  248. André

    Sorry, here comes the header.php code:

  249. André

    <?php
    function my_init_method() {

    wp_deregister_script( 'jquery' );
    wp_register_script( 'jquery'
    , 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js');

    }

    add_action(‘init’, ‘my_init_method’);
    ?>

  250. Ced

    Great Tutorial,
    wondering if you knew how the menu at http://www.bu.edu was pulled off. same ideal but contained to move the content down.

    thanks

  251. aiphes

    hi

    does exist an adaptation for drupal ?

    thanks

  252. snehal

    Hi, Menu working great but only one problem. Please help me. I want to make it transparent drop down with use of PNG but in IE 6 7 8 not showing transparent. I don’t know why this is happen. In Mozzilla It is working good. Please help me.

  253. Justin..

    It is a beautiful script. but I cannot get it working right. It is even hard for it to display for me.

  254. Justin

    sorry i got it now. i must’ve been an idiot for a few minutes.

  255. Bedava

    It is a beautiful script. but I cannot get it working right. It is even hard for it to display for me.

  256. curcuna

    thanks, great a information.

  257. pro-gadget

    Great tutorial , but i would be really greatful if you could pass us the images so we could understand the tutorial in a better way and we gain a benifit from it

  258. Sylvia

    Hey I have been trying to implement this for days. I almost have it working but all the text in the drop down menu overlaps each other into one line. All the text is jumbled on top of one another. I am not that great in troublshooting CSS but I am thinking there is something conflicting. I have just this in one page so that I am not conflicting with something else. Any idea what causes this? I really love your version here so I would like to use this one.

  259. Josh

    I don’t know, man. I’ve tried out other jquery mega drop down tutorials, but so far this is the most painful. I’ve been going over and over and over this, and trying to resurrect the demo, and all I am staring at in the past nearly 40 minutes is just a blank screen. Nothing’s working. So I have no clue what all these people have done to regard this tutorial “great”, but clearly I don’t know what I’m doing. What I don’t understand, why I did not have any problem recreating other mega dropdowns. I am at a loss here. Either way, sorry, but I’m not wasting any more time on this one.

  260. Steven Sterling

    Great tutorial!! I just got it implemented and switched up some of my graphics to suite my site. The z-index issue also didn’t seem to be a problem. Thank you so much, I was looking around for weeks and this was the easiest one out there.

    PS to the comment above, Josh, it sounds like you are just copy + pasting and maybe not having any of the background images? You should take a look at the CSS, they are calling background images which means you must have them to avoid the blank screen. Doh!

  261. John

    Great post, I always design dropdown menu with float div layout before, I never saw this great code like code. very very nice post!!! thanks.

  262. alan

    To much code for an simple effect.
    It can be done with less code in css with only!

    But thanks anyway !

  263. JeV

    @Alan
    So show us ignorant coders instead of just stating it…

  264. tosh

    @alan – i’d be interested to see your pure CSS version??

  265. Online izle

    It is a beautiful script.

  266. Mark

    Great work. Thank You!

  267. dlogic

    This is the best Mega Dropdown so far! Awesome, I like your work! Well done!

  268. J. Bruni

    Thanks a lot!

    In my customized implementation of your mega drop down, I changed the “h2″ tags to another tag.

    IMHO, header tags should not be user for the menu items. Header tags should be used for… headers. :-)

  269. Tyler

    Can’t seem to get the menu to pop up on mine. I’m not sure if I missed a step or what, but it doesn’t seem to be activating the script upon hovering.

    test page: http://abovegroundmagazine.com/underground-hip-hop-son

    Any help is very much appreciated.

  270. harika

    Great Article. Thank you. I like it an I want to do it:))

  271. G

    This menu doesn’t work with Javascript disabled, is they a version that can overcome this?

Speak Your Mind...

Post HTMLNeed to Post HTML Code? Use Postable to post code friendly html. *Wrap all html code in <pre></pre> tags.
Post HTMLNeed to Keep Updated with Comments? Subscribe to comments now.

CSS Gallery