CSS3 dropdown menu

Today you’ll learn how to create your own CSS3 dropdown menu, without any additional Javascript code. There are no images used and, as usual, minimal HTML markup. Let’s see how is made:


If you’re in a hurry, here’s the result:

View demo

HTML structure

As you can see in the following lines, the HTML structure does not contain more than we need, it’s a minimal one and easy to understand.

<ul id="menu">
	<li><a href="#">Home</a></li>
	<li>
		<a href="#">Categories</a>
		<ul>
			<li><a href="#">CSS</a></li>
			<li><a href="#">Graphic design</a></li>
			<li><a href="#">Development tools</a></li>
			<li><a href="#">Web design</a></li>
		</ul>
	</li>
	<li><a href="#">Work</a></li>
	<li><a href="#">About</a></li>
	<li><a href="#">Contact</a></li>
</ul>

One more thing, also very important, this is semantic HTML. It’s a logical structure and has a correct meaning, even if styling is totally missing at this point:


Clean and accessible HTML structure

In my example, the “Categories” section is the only one who contains a sub-list, but you can easy add sub-lists to any item.

The CSS

/* Main */
#menu
{
	width: 100%;
	margin: 0;
	padding: 10px 0 0 0;
	list-style: none;
	background: #111;
	background: -moz-linear-gradient(#444, #111);
    background: -webkit-gradient(linear,left bottom,left top,color-stop(0, #111),color-stop(1, #444));
	background: -webkit-linear-gradient(#444, #111);
	background: -o-linear-gradient(#444, #111);
	background: -ms-linear-gradient(#444, #111);
	background: linear-gradient(#444, #111);
	-moz-border-radius: 50px;
	border-radius: 50px;
	-moz-box-shadow: 0 2px 1px #9c9c9c;
	-webkit-box-shadow: 0 2px 1px #9c9c9c;
	box-shadow: 0 2px 1px #9c9c9c;
}

#menu li
{
	float: left;
	padding: 0 0 10px 0;
	position: relative;
}

#menu a
{
	float: left;
	height: 25px;
	padding: 0 25px;
	color: #999;
	text-transform: uppercase;
	font: bold 12px/25px Arial, Helvetica;
	text-decoration: none;
	text-shadow: 0 1px 0 #000;
}

#menu li:hover > a
{
	color: #fafafa;
}

*html #menu li a:hover /* IE6 */
{
	color: #fafafa;
}

#menu li:hover > ul
{
	display: block;
}

/* Sub-menu */

#menu ul
{
    list-style: none;
    margin: 0;
    padding: 0;
    display: none;
    position: absolute;
    top: 35px;
    left: 0;
    z-index: 99999;
    background: #444;
    background: -moz-linear-gradient(#444, #111);
    background: -webkit-gradient(linear,left bottom,left top,color-stop(0, #111),color-stop(1, #444));
    background: -webkit-linear-gradient(#444, #111);
    background: -o-linear-gradient(#444, #111);
    background: -ms-linear-gradient(#444, #111);
    background: linear-gradient(#444, #111);
    -moz-border-radius: 5px;
    border-radius: 5px;
}

#menu ul li
{
    float: none;
    margin: 0;
    padding: 0;
    display: block;
    -moz-box-shadow: 0 1px 0 #111111, 0 2px 0 #777777;
    -webkit-box-shadow: 0 1px 0 #111111, 0 2px 0 #777777;
    box-shadow: 0 1px 0 #111111, 0 2px 0 #777777;
}

#menu ul li:last-child
{
    -moz-box-shadow: none;
    -webkit-box-shadow: none;
    box-shadow: none;
}

#menu ul a
{
    padding: 10px;
	height: auto;
    line-height: 1;
    display: block;
    white-space: nowrap;
    float: none;
	text-transform: none;
}

*html #menu ul a /* IE6 */
{
	height: 10px;
	width: 150px;
}

*:first-child+html #menu ul a /* IE7 */
{
	height: 10px;
	width: 150px;
}

#menu ul a:hover
{
    background: #0186ba;
	background: -moz-linear-gradient(#04acec,  #0186ba);
	background: -webkit-gradient(linear, left top, left bottom, from(#04acec), to(#0186ba));
	background: -webkit-linear-gradient(#04acec,  #0186ba);
	background: -o-linear-gradient(#04acec,  #0186ba);
	background: -ms-linear-gradient(#04acec,  #0186ba);
	background: linear-gradient(#04acec,  #0186ba);
}

#menu ul li:first-child a
{
    -moz-border-radius: 5px 5px 0 0;
    border-radius: 5px 5px 0 0;
}

#menu ul li:first-child a:after
{
    content: '';
    position: absolute;
    left: 30px;
    top: -8px;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 8px solid #444;
}

#menu ul li:first-child a:hover:after
{
    border-bottom-color: #04acec;
}

#menu ul li:last-child a
{
    -moz-border-radius: 0 0 5px 5px;
    border-radius: 0 0 5px 5px;
}

/* Clear floated elements */
#menu:after
{
	visibility: hidden;
	display: block;
	font-size: 0;
	content: " ";
	clear: both;
	height: 0;
}

* html #menu             { zoom: 1; } /* IE6 */
*:first-child+html #menu { zoom: 1; } /* IE7 */

Quite long list, huh? This is it…

CSS shape

You may have noticed the triangle shape that appears along with the sub-menu. That’s a CSS shape and its purpose is to increase usability for this CSS3 menu.

It’s made using the :after pseudo-element:

#menu ul li:first-child a:after
{
    content: '';
    position: absolute;
    left: 30px;
    top: -8px;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 8px solid #444;
}

#menu ul li:first-child a:hover:after
{
    border-bottom-color: #04acec;
}

Taming the IE6 “beast”

The sub-menu is displayed when hovering on a li element. As you already know, IE6 doesn’t support hovering on a non-anchor element.

Although, at the beginning of this article I said “without any Javascript”, in order maintain accessibility also for IE6, please allow me to add some scripting code:

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript">
	$(function() {
	  if ($.browser.msie && $.browser.version.substr(0,1)<7)
	  {
		$('li').has('ul').mouseover(function(){
			$(this).children('ul').show();
			}).mouseout(function(){
			$(this).children('ul').hide();
			})
	  }
	});
</script>

You may skip that, as IE6 is going down. The final countdown began!

The above solution requires Jquery. Also, I think this shouldn't be a problem at all, while, nowadays Jquery is almost "a default" when talking about modern websites.

Target IE6 & IE7 browsers

Besides this Jquery fallback, the above CSS includes some lines specifically for IE6 and IE7:

* html #menu             { zoom: 1; } /* IE6 */
*:first-child+html #menu { zoom: 1; } /* IE7 */

There are also other IE hacks that won't pass CSS file validation... If you don't like it this way, just use conditional comments!

View demo

The end (of this article)

Hope you enjoyed this tutorial, don't forget to leave a comment!

Later edit

Just as I promised, the CSS3 dropdown menu is now a multi-level one. Please check the demo page to see the updated version:

Another update

I took advantage of some free time and I updated the CSS3 dropdown menu demo:

Related content

Written by Red

Catalin Rosu, a.k.a Red, is a professional web designer and developer who loves to be creative and enjoys CSS techniques. Stay tuned for latest updates, subscribe to RSS and follow him on Twitter.

205 Responses to “CSS3 dropdown menu”

  1. A great demonstration of the power of CSS3!
    I also like the implemented fallbacks for older browsers.
    Kudos!

  2. Andrei says:

    It is very nice; to bad it does not support at least one more deepness level.

  3. This is really cool. Love it. Thanks so much for posting the details.

  4. Dawn R says:

    Thank you. This is such clean beautiful code, it inspires me to try hand coding my first drop down menu. Also, the little arrow is very cool for increased useability.

    I also like that you include support for IE6; I may not like it, but poor people use it and need to use websites too. I will email back the URL of the site I implement it at!

  5. Mohammad Samir says:

    Nice tutorial, liked it

  6. Raju Mishra says:

    thanking you regarding this articles
    Please continue to send me this type of articles.
    I am always waiting for you..

  7. Anders Hansen says:

    Looks really nice. I tried getting the submenus to fade in with some code i got somewhere else, couldnt get it to work though.

    -webkit-transition:0.25s linear opacity; /* Make the dropdown fade-in in Webkit */

    I’m really bad at css, any good suggestions on how to achieve this functionality?

    • Red says:

      Thanks Anders!
      In order to achieve the effect you wish, you may try using opacity property instead of display:

      #menu ul
      {
        opacity: 0;
      }
      
      #menu li:hover > ul
      {
        opacity: 1;
        -webkit-transition: opacity 1s linear;
      }
      

      For browsers like IE, don’t forget to add also a fallback.

  8. Ashish says:

    Wow, best menu ever, and the best part of it is, this works fine in older versions of IE like IE6 and IE7 also.

    May be this is happening because of jQuery but anyway, this is gr8!

    Thanks!

  9. tomsky says:

    Nice one, thanks mate!

  10. Red says:

    @uJuan and @tomsky thanks for your comments!

  11. ggfan says:

    It’s cool but It’s not multi-level …

  12. ratesman says:

    It’s cool, thanxs :)

  13. jackiller says:

    i love CSS3, i love html5, but i do not love IE.

  14. vitmel says:

    Nice article, will use it in some projects. Simple code, i like it. What do you use to test your code in IE6?

    • Red says:

      Thanks for reading it vitmel! I use IEtester for this because I find it very helpful.

      Alternatively, I also use a Virtual Machine that runs Windows XP with default IE6 installed :).

  15. Kuitsi says:

    Opera 11.10 supports linear gradient

    background-image: -o-linear-gradient(top, #444, #111);

    Thanks for great menu

  16. Vladimir says:

    Good job on the code man…
    Thanks for sharing :)

  17. Mars says:

    that is so nice, adding to my bookmark

  18. Sagu Joshi says:

    Most Awesome Tutorial by Red! You Guys are Fantastical and the best! Great Tutorial!

  19. manish says:

    Great tutorial, its awesome.

  20. Aaron says:

    Hey Red,

    Great Tutorial!

    Thank you very much!

    Question, what browser’s is the CSS code compatible with? Would you happen to know on hand?

  21. Red says:

    Aaron, thanks.

    Regarding your question, this is a cross-browser solution using progressive enhancement.

    This menu, using the above Jquery lines, will work also on IE6.

  22. Gerben says:

    Thanks for this great tutorial.

  23. RicardoB says:

    thx, great tut. i´ll be on it today.

  24. Kien Huynh says:

    Thanks for sharing! It nice! I like it! Good job :)

  25. Shaun_R says:

    Hey, nice work with this, it’s come in extremely handy for a project I’m doing right now! Thanks.

    One question, I have a non-white background, but the menu seems to have a white background. Is there a way I can make this a different colour, so that it blends in with the background colour?

    Thanks!
    Shaun

    • Red says:

      Shaun, nice to hear you find this helpful.

      There is no white background for this menu, so you shouldn’t encounter any problems when implementing it.

  26. alex says:

    Thank you for the hack, I am Brazilian and I would love that you put a translator on your site, since agradesso ja!

  27. Gunasegar says:

    Hi its nice tutorial… i want the submenu to display only onclick of the main menu… how to do it with jquery…

    • Red says:

      @Gunasegar, I hope you have good reasons to do that. :)

      Technically, you’d need to remove the following CSS rule #menu li:hover > ul {display:block} and use the above jquery code with click instead mouseover event.

      This should work!

      • Gunasegar says:

        Yep i will try that…. am using this menu as a part of my topbar, where the submenu is not visible, hiding behind the top-bar… actually absolute position is notworking… any idea…

      • Gunasegar says:

        $(function() {
        $(“#menu li”).click(function toggle(){

        $(this).children(‘ul’).toggle();
        $(this).toggleClass(“active”);

        return false;
        });

        this jquery code is working…. and comment the
        #menu li:hover > ul
        {
        display: block;
        }
        this hover property…

        Now the problem is absolute position… i tried given the parent div position as relative but still i have the problem… any suggestions?

        • Red says:

          Gunasegar, check your styles again and if you still encounter problems, send me an email using the contact form.

  28. Gary says:

    I have a vertical menu on bottom left column . Can I change css3 menu to work as vertical . I also have another problem . I am using wysiwyg editor for existing left column menu but it does not recognise link to style sheet. I tried ref style in head of site and also in wysiwyg but does not work for either so I am using wysiwyg styles for now.

    • Red says:

      Gary, this menu can be easily transformed into a vertical one. You should just update some CSS lines like absolute positioning top and left coordinates. Also you should remove some floats in order to transform the menu into a vertical menu.

      Regarding your WYSIWYG editor, I’m afraid I can’t really help you.

      Good luck!

  29. alucard says:

    hi!
    I modified the colours of the menu.in dreamweaver i see the modifiction but in a browser (chrome,firefox….) no.
    plz help me
    thanks :)

  30. Aris says:

    Is there any update on getting this to work correctly in IE 7?

    • Red says:

      This menu is already working correctly in IE7, if you need CSS3 rendering for IE6/IE8 you could try http://css3pie.com/

      • Aris says:

        yeah, I just meant for the rounded corners…but i ended up using a hack to get the rounded corners…but the hack uses javascript, which I wanted to eliminate completely from the site

        but just needed to make sure the site is accessible with or without javascript enabled…if they don’t have it enabled, square corners is fine with me…

        good stuff anyway

  31. Edwin says:

    This is really cool. Love it.

  32. rriver says:

    Thank you gor the nice tutorial!
    Do you know if there is a way to hide the menu when tapping outside on mobile Safari?

    • Red says:

      rriver, I’m glad you found this useful!

      Regarding your request, didn’t tried it but I think you’d need some conditional JS (only for iOS). Then, using something like Jquery’s event.stopPropagation() you could detect when the user taps outside the menu and hide the sub menu.

  33. Anonymous says:

    :) normally… i never stop to comment – but i saw that well, one, the stuff here is absolutely amazing, and two, you are one of the few people that actually respond to their users :D

    great job, i cant/couldnt believe that something this spectacular was possible!!!! x]

  34. behnam says:

    very very gooooooooooood
    thanks

  35. Damian says:

    I was wondering if this is under the Creative Commons license, or if I need your express permission to use this code? Thank you!

  36. Justin says:

    Hello,

    Love the menu and plan to use it even with the bug i have. You might be able to solve the bug, i have a fix i dont like but might use.

    When going website link i attached to this comment. On products we have menu headers to specify a standard. It is just a plain “li” with out the “a” link as there isnt a page we plan to have for it. I lose the CSS up arrow shape on that drop down. I could put a “a” with a null so when clicked it doesnt go anywhere but i prefer the menu header not highlight like it does now as it doesnt represent a link.

    Is there any way to fix the arrow or am i going to have to use the “a” null method to get the arrow in place?

    Thanks,
    Justin

    • Red says:

      Justin, sorry for my late reply.

      You could use an alternative tag as a span (styled the same as the anchor except the highlighting you want to be removed).

      I hope this works for you!

  37. Jan says:

    Hi, can you please explain to me why clearing the floated elements is necessary or perhaps why does the menu act the way it does (the background color does not take effect) when the clear fix is not applied?

    And how does this look like in tablets or mobile devices?
    Thanks. :)

  38. mubarak k k says:

    hi,
    Thanks ! its very useful for people like me .

  39. Angelo says:

    Hi, hehehehe, i just make it work now, but i really would like the code for the multilevel menu, thanks very much, it was very instructive, i learn too much
    thanks again

  40. Track says:

    And I want the same

  41. Red says:

    Angelo and Track, you just need to view the demo source for the multi-level code.

  42. eal says:

    Outstanding menu. Looks pretty and works like a champ. It’s capable of customization as between top level menus and submenus, which is just what I needed. I’m a CSS noob and found it easy to deploy. Much easier to use with dynamically generated links than other menus I found, because it does not require you to use special class or ID tags for each level.

    Thank you so much for designing this!

  43. Shreyas says:

    It’s really awsoume thanx for sharing…!!

  44. Red says:

    Shreyas & Rahul, thanks guys!

  45. Great content and good explanation as well. Thanks for sharing.

  46. Nathan says:

    Friend i’m a new blogger. I’m interested to implement your drop down menu bar in my blog ,but i don’t know how to enter the css code and how can i get the output in my blog. please explain for me, what are the steps i have to follow to obtain the menu bar in my blog. I have no technical knowledge. Please explain for me step by step procedure for implement the above css code technique. If possible, send it to my mail….Help me friend. I am waiting for your reply.

    • Red says:

      Nathan, technically, this menu is not hard to implement as you probably read. Basically you’d need just to copy/paste the HTML and CSS above.

      But, when it comes about implementing with a blog (which is a CMS), things can become a little tricky and you’d need to have some basic knowledge about web development.

      Good luck!

  47. henry says:

    hey red , thanks for this . i’ll be using this one for my next project .

  48. Balwan says:

    Thx buddy for this lovely dropdown menu. :)

  49. zestq says:

    Im adding this link in ma favourites n hope will implement it soon ;)

    anyways reali gr8 post dude…

  50. Red says:

    Henry, Balwan & Zestq thanks guys!

  51. YJ says:

    Hi Red,

    Excellent code.

    May I know how to center the menu? Thanks.

  52. Erol says:

    nicely done.. u are the man!!!

  53. carrie says:

    Thanks a lot for this nice tutorial. Can’t wait to use it.

  54. Jeff-H says:

    Hey just wanted to say thanks that’s great work! Got a quick question whats the > for in #menu li:hover > a ?
    I’ve got a handle on basic css but I’ve never seen the > used before. Looking for some info or where I can learn about this.

    Keep up the great work!!

  55. Marius says:

    It does’nt work on internet explorer….and when i make a css whit that code it doesn’t work, but if i implement in the index it works…why? i’m new….
    Thank you

  56. Majid H says:

    You are awesome man. I cant believe i can go this far with only CSS. I hate using images i navigation menus, so thanks for this great tutorial. I will use this in my blog at Blogger Tricks.

  57. Daniel says:

    Thanks for the code. It’s great.
    So, I used your code and changed it a bit so I could use on my vertical menus.
    But, I was unable to make the Sub-Menu appear after the button. I want it on the right. But, it keeps appearing on the bottom. I guess it is something on the code that you used to make it appear on the bottom, because your dropdown menu is for horizontal menus. Can you help me?

    • Red says:

      Daniel, I’m happy to hear you are using my menu.

      To make it look better as a vertical menu, you may need to adjust the left and top properties for the #menu ul.

  58. Adam says:

    Really good tutorial but cant get it to work correctly in ie7 or 8. changing z-index doesnt seem to help, think gradient or rounded corner hacks need adjusting? any ideas?

    thanks

  59. Dino says:

    Hi, thanks for this wonderful tutorial

    if you have only one sub Menu Item, the round corner effect is only for the bottom corner.

    add this to you css and all corner will be rounded

    #menu li:first-child:last-child > a {
    @include border_radius(5px, 5px, 5px, 5px);
    }

    regards dino

    • Dino says:

      sorry, forgot to remove SASS

      remove
      @include border_radius(5px, 5px, 5px, 5px);

      and add
      -moz-border-radius: 5px 5px 5px 5px;
      -webkit-border-radius: 5px 5px 5px 5px;
      border-radius: 5px 5px 5px 5px;

    • Red says:

      Dino, that’s a good point if you’re using just an element as a submenu. ;)

  60. Hélio Moreira says:

    Didn’t work in IE 9 :(

    Already fix?

    Thanks a lot.

    Best Regards,
    Hélio

    • Red says:

      Hélio, the CSS3 dropdown menu does work very well on IE9.

      Is just that CSS3 gradients feature is missing. The good news is that IE10 supports a lot of CSS3 features, including gradients.

  61. Hélio Moreira says:

    the style (css) is not in the same page by the rest of code.

    (sorry my english)

    Best regards,
    Hélio

  62. Hélio Moreira says:

    Hi again,

    I tried for running in IE9, but the submenus do not work. Only the top menu appears.

    In Firefox works fine.

    Can you help me?

    • Red says:

      Hi again Helio,

      This menu is working across all browsers, including IE9. Also, it works also on IE6/IE7/IE8. Please check your code.

      • Hélio Moreira says:

        I didn’t make any changes in the code…

        The only diference is :

        I put the css in a css file… the rest is the same… :(

  63. Aminul Islam says:

    Owa,
    Thanks Man for Great And Good menu.

  64. Mito says:

    Hiya,

    Really liking your design.

    When I view the example it looks fine but when I create it mayself I dont get the rounded corner to the left of the menu.
    Any idea why?
    They are just straight.

    Thanks

  65. DJEROCK says:

    I have been able to manipulate the width of the sub menu. Is there a way to get the menu to align left and have the little triangle come underneath the link?

  66. Good Share İt Now Started

  67. cieux75 says:

    hi and excuse me for my bad english
    How to put the text in the middle of the menu and not to the left completely

    thank you !

  68. cieux75 says:

    thank you Red !!!
    it’s exactly what I want

  69. Mike says:

    Hi – great menu, thanks. Two questions:

    1) does your menu system support titles of different lengths, without having to assume a maximum menu title width?

    2) is there a way to always show when a menu item has a sub-menu? Currently, you only find that out when you mouse over the menu item.

    Thanks

    • Red says:

      Mike, I’m glad you like this menu.

      Also, regarding your questions:

      1. Not sure if I got it right but I’m not aware of any menu length problem. The only width set for this menu is for IE7 and below (for compatibility reasons).

      2. This menu does not support that. But, it can be added by simply using a CSS class for the main items that contain a sub-menu. That class can display an arrow or something similar. I didn’t made that initially because I thought it would be quite redundant as the sub-menu already has something like that .

  70. kevin says:

    love the look, But what do I need to do to put a logo above the menu bar?

    • kevin says:

      Let me explain that. I can add an image, but then IE makes your menu and the rest of the page move right of that first image.

      Home
      About……….
      (followed by the rest of your code)

      Btw looks awesome as is in firefox and opera

      • kevin says:

        opps html code lost there.

        table width=”950″ align=”left”
        tr img src=”images/slogo.png” alt=”" align=”center”
        /tr
        /table

        ul id=”menu”
        li a href=”index.html”>Home /a /li
        li a href=”about.html”>About /a /li……..

        there (without the greater than and less than)

  71. oli says:

    Hi,
    your menu is great….but when i tried to use it then i face some problem…
    i used this code for keep all web content in center place…

    so can you please give me the css code of the menu sothat i can use the css “container” and can use the layer to place the menu in the right place?
    one more help please…
    i can’t understand where i put the extra code for IE 6/7…i tested this menu only working well in IE9
    if you can put the code in the css then i will be very grate full to you…

    please help me…i like your menu very much that way i am trying to use it…..
    waiting for your kind reply… :)

    Thanks
    oli

  72. oli says:

    Sorry…i can’t write code here so please check this link to see what i wanted to say
    http://zoomlancer.ucoz.com/t_232.htm
    thanks
    oli

  73. Danni says:

    Thank you very much for this! I’m teaching myself (by necessity as well as interest), and was looking for something that looks great, and that I could also understand! From a newbie point of view, the code is simple and elegant (as is the menu). A lot of tutorials I’ve seen have a whole lot of unnecessary divs and codey bits that I can’t seem to figure out what they do.

    Also, thanks for the IE workarounds – that has helped preserve my sanity.

    Thanks so much for sharing.

    Regards,
    Danni

  74. Tony says:

    the menu is great for what I need. thank you. the only problem I’m having is getting the 2nd tier sub menus to display to the right. they are appearing below on both IE , firefox and Chrome.

    • Tony says:

      Never mind. I’m such a dork.. forgot the java… thanks again for such an simplistic looking menu. No way I could have built this with my skill set. Glad there are still people out there like you..

  75. 737Capt says:

    What do I need to change to make the menu look like the original. The demo is much more rounded and does not have the lines in between menu items. How can I add those back in? Thanks!

  76. Tony says:

    Thank you Red, it is a great tutorial. However with “copy and paste” I found two problems there. (http://sg-dvr.blogspot.com/)
    1) 2nd level menu “Development tools” and “Web design” under “CATEGORIES” drop down properly but they are un-accessible when I try to move the cursor on them. I searched Internet and everybody says it is because of IE z-index issue. I tried to change z-index but it doesn’t work.
    2) The trasparent 2nd level menu overlaps with the 1st level menu at the 2nd row. When I try to access “CSSSSSS” under “CATEGORIES” the 1st level menu “ABOUT6″ below “CATEGORIES” is selected instead.
    Please help on these. Thank you.

    • Tony says:

      I tested with Firefox. Everything is OK. Only IE8 has above problems. Even worse, those cool features are all gone in IE8. Since there are still quite a lot people using IE, could you please take a look and update your codes? Thank you!!!

    • Red says:

      Hey Tony, thanks for your comment.

      Regarding the problems you’ve found: I never thought this menu will have 2 rows, never. Also, it does not look good either. :)

      So, I’d recommend you to stick always to one row and you’ll not have any problems on IE8 and below.

      Cheers.

  77. Octo says:

    magnificent short cut to drop down menu. forget writing long java script, RED u showed me the power of CSS. Thnx

  78. Leaner says:

    Hello!
    I am a newbie in coding and I’m learning,i have some question for this menu.
    The one:
    I can not see the effect in IE6/IE7/IE8.But in FireFox I can see the result . I do not know why?

    • Red says:

      Hi, for IE6 there is a jQuery workaround. Check the short jQuery snippet above. There are no problems on other browsers, just check your code again. Good luck!

  79. Prodyot Pran says:

    Dear Red
    Thanks a lot for the above tutorial.
    Finally I found a working tutorial in the net and it is yours.
    For a beginner like me it is very important to have a “copy/paste/test/learn” type of tutorial.
    I copy pasted your tutorial material and also from the source code of your demo page and “Hola”- it came out great.
    Thereafter I jumped into the codes to see what has been put where and why.
    This facility of “copy/paste/test/learn” tutorial provided by you had encouraged me to take more interest.
    Many tutors would not even explain why he/she put a particular code in a certain but specific location. It is very frustrating to follow them even if they end up building great apps.
    Thanks again.

  80. takman says:

    when i add a scroll bar to the sub menu, i lose the little triangle pointer. I tried changing code around to make it appear but no luck..

    this is the code i added to the #menu ul

    overflow-y: auto;
    height:300px;
    width: 250px;

  81. takman says:

    also, how can i keep the main menu from changing size when i zoom in and zoom out? When i zoom IN, it bunches everything together. When i zoom OUT, it stretches the bar. I’d like it remain static, unchanging.

  82. padawan says:

    this is awesome. you are a legend. songs will be written about you years from now :-)

  83. 大兜 says:

    這實在是太神了!尤其是那個小三角形,這種 boarder 的活用,我這輩子也想不到吧!從這篇文章學到很多,萬分感謝!

    Thanks a lot!

  84. Craig says:

    Hey Red,

    I’m having problems getting the menu to work in IE, I’ve looked over the code as well as the JQuery info several times and I was wondering what you would recommend?

    Cheers,

    Craig

    • Red says:

      Craig, for IE6, please check if your code contain the above jQuery code, including the library inclusion itself:

      <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
      
  85. Craig says:

    Hello again,

    I have re-added the jQuery code, however it made no difference. Any other possibilities?

    thanks,

    Craig

  86. Alexander says:

    This menu is wonderful. I am having some issues though. I am building a site with many pages and I have the menus on each one. I’ve moved the CSS code to it’s own .css file. On each of my pages I have the JavaScript tags in place so it works with IE, but when I load the site in IE, hovering over the options doesn’t bring up the sub-menus, and the black background doesn’t show. The menu works in all other browsers.

    Any thoughts?
    Alexander

    • Red says:

      Alexander, perhaps you can send me a link using the contact form. I’ll take a look.

      • Alexander says:

        Thanks Red, but I found the issue. I was looking around and IIS 7 has some funny personality traits.

        I put this line of code on the top of my HTML page and just like that, IE works:

  87. Mychael says:

    I was having problems getting the drop down menu to work under IE9. Both the background color, and the drop menu would now show up. It killed a good 3 hours of my day. Then I remembered a problem I had before where all I needed to do was change the doctype to strict, so I did and voila! It’s works perfectly now (minus the gradient). I figured I would post this and maybe help the rest of the people battling with IE9. Thank you so much for sharing your code!

  88. Red says:

    Mychael, you can start using the new HTML5 <!DOCTYPE html>. Just forget about Strict or Transitional doctypes!

  89. Sweety says:

    Hello

    I’m 15 and I’m a newbie in webdesigning.

    Is there anyway I can center the ‘Home’ ‘Categories’ etc … in the grey rounded rectangle ?

    Thank you by the way, your menu is awesome and I’m going to use it.

  90. Red says:

    Hello Sweety, please check the comments above. I already made a jsFiddle with a similar request.

    • Sweety says:

      Thank you. But can you please point the differences ? I mean, in the first code, you use float, and now you use display.

      By the way, is there a place I can put my code ?

  91. Heris says:

    Hi!!!

    I have a problem when inserting the menu css code on my website, all other libraries stop working. could help make my website work properly?

  92. Frank says:

    Using the same css I can just add a deeper level of submenus in the html?
    I tried to do so but it showed the level below the menu, not on the right side.
    Help here. Thanks. I really like how it looks.

    • Red says:

      Hey Frank, the menu already has three sub-levels. I would not recommend you adding one more.

      If you still want that, you will need to add some more ul rules.

  93. Jonhard says:

    Hi Catalin

    Nice dropdown menus. Just what I am looking for.

    I was wondering how I can have a gap between the main menu and the dropdown. I have tried making top: 45px; in #menu ul This works fine, the dropdown comes down, but now I have problems fetching (hover over) the dropmenu when I move from main to the dropdown.

    Regards
    jonhard
    faroe islands

    • Red says:

      Thanks for your comment Jonhard.

      The fact is that you can’t add a gap there and still have the same functionality. Having no gap between list element trigger and the sub list is actually a trick that makes these CSS dropdowns possible. Hope that helps!

  94. ganapathi says:

    its really good tutorial

  95. Janner says:

    Los felicito por este aporte tan bueno, segui todo el tutorial y no genero ningun problema.. felicitaciones..

  96. Christine says:

    Fantastic great code, Red! You are very clever. I just wonder; are you able to guide me on how I implement this in a joomla-template?

    • Red says:

      Christine, I’m not a Joomla expert, but I’m sure you will not have problems with implementing this dropdown menu.

      Basically, once you have a dropdown on Joomla, you just need to adapt these dropdown styles to fit.

  97. Bala says:

    Really a nice one to implement easily

  98. Thanks for this tut. Even though I am using my own CSS menus, this tutorial helped me with first-child hover events. Thanks again!

  99. steve says:

    Great article.

    I am floating menu the main ul over a grey background having taken the dark background out and it looks very effective.

    Thanks.

Leave a Reply