Nitesh is back to blogging.. Apologies for no updates since last 2 months..
TopBottom

Multi level drop down menu for blogger

Posted by Nitesh Kothari on 12 December 2008
Share this post:
Ma.gnolia DiggIt! Del.icio.us Yahoo Furl Technorati Reddit

A good site navigation is very important. Every visitor or reader searches for the navigation to read more and more on the blog. I have visited many sites which do not have a site navigation at all. It becomes really difficult to search something on such blogs. I believe, one should have a multi level drop down menu, which gives better accessibility of the content to the readers. Using such menu, it becomes very easy to check almost all blog posts of a blog. Taylor Thompson, owner of Video blogging tips mailed me and asked how to design a drop down menu for the website or blog, so i decided to write a tutorial about it.


Step 1: CSS Code
Copy and paste following code just above </b:skin>

#NavbarMenu {background: #72a8d2;width: 100%;height: 25px;font-size: 12px;font-family: Arial, Tahoma, Verdana;color: #FFF;font-weight: bold;padding: 0;vertical-align:middle;margin-bottom:5px;}

#nav {margin: 0;padding: 0;vertical-align:middle;}
#nav ul {float: left;list-style: none;margin: 0;padding: 0;}
#nav li {list-style: none;margin: 0;padding: 0;}
.current_page_item {background:#dee5e5;color:#2299ff;border-bottom:1px solid #dee5e5;}

#nav li a, #nav li a:link, #nav li a:visited {color: #FFF;display: block;font-size: 15px; font-family: Georgia, Times New Roman;font-weight: normal;text-transform: none;margin: 0; padding: 3px 15px 3px;text-decoration: none; }

#nav li a:hover {background: #dee5e5;color: #2299ff;margin: 0;padding: auto 15px auto; text-decoration: none;vertical-align:middle;border-bottom:1px solid #dee5e5;}

#nav li a:active {background: #dee5e5; color: #2299ff;margin: 0;padding:auto 15px auto; text-decoration: none;border-bottom:1px solid #dee5e5;}

#nav li li a, #nav li li a:link, #nav li li a:visited {background:#555; width: 150px; color: #FFF; font-size: 14px; font-family: Georgia, Times New Roman; font-weight: normal; text-transform: none; float: none; margin: 0; padding: 7px 10px; border-bottom: 1px solid #FFF; border-left: 1px solid #FFF; border-right: 1px solid #FFF;}

#nav li li a:hover, #nav li li a:active {background: #777; color: #FFF; padding: 7px 10px; }

#nav li {float: left; padding: 0;}
#nav li ul {z-index: 9999; position: absolute; left: -999em; height: auto; width: 170px; margin: 0;padding: 0;}

#nav li ul a {width: 140px;}
#nav li ul ul { margin: -32px 0 0 171px;}
#nav li:hover ul ul, #nav li:hover ul ul ul, #nav li.sfhover ul ul, #nav li.sfhover ul ul ul {left: -999em;}
#nav li:hover ul, #nav li li:hover ul, #nav li li li:hover ul, #nav li.sfhover ul, #nav li li.sfhover ul, #nav li li li.sfhover ul {left: auto;}
#nav li:hover, #nav li.sfhover {position: static;}

Step:2 HTML Code
Copy and paste following code to body section(wherever you want to place this dropdown menu).

<div id='NavbarMenu'>
<ul id='nav'>
<li><a expr:href='data:blog.homepageUrl'>Home</a></li>
<li>
<a href='#'>Blogger Hacks</a>
<ul>
<li>
<a href='#'>Most Popular</a>
<ul>
<li><a href='#'>Sub Sub Page #1</a></li>
<li><a href='#'>Sub Sub Page #2</a></li>
<li><a href='#'>Sub Sub Page #3</a></li>
</ul>
</li>
<li><a href='#'>Most Recent</a></li>
<li><a href='#'>Most Commented</a></li>
<li><a href='#'>Top Rated</a></li>
<li><a href='#'>All Blogger Hacks</a></li>
</ul>
</li>
<li><a href='#'>Blogger Widget</a>
<ul>
<li>
<a href='#'>Most Popular</a>
<ul>
<li><a href='#'>Sub Sub Page #1</a></li>
<li><a href='#'>Sub Sub Page #2</a></li>
<li><a href='#'>Sub Sub Page #3</a></li>
</ul>
</li>
<li><a href='#'>Most Recent</a></li>
<li><a href='#'>Most Commented</a></li>
<li><a href='#'>Top Rated</a></li>
<li><a href='#'>All Blogger Hacks</a></li>
</ul>
</li>
<li><a href='#'>Blogger Templates</a></li>
<li><a href='#'>Tag Cloud</a></li>
<li><a href='javascript:togglediv("headlines")'>Headlines</a></li>
</ul>
</div>

Final Words
I am not explaining this hack in detail, because i will be writing a detailed post about multi level drop down menu which works in all the browsers. This menu does not work well with IE. submenus don't appear on mousehover. Expect a better version soon. Leave a comment here, if you have any doubts or queries.

18 comments:

Taylor said...

Thanks for the post. I am looking for menus that work in all browsers. (As you could imagine.) Lol. But I will throw up a link to your site in my blog roll.

If you'd like the link to change to a DoFollow link, let me know the anchor text you'd like me to use, and then I will fix that for you if you also add me to your blog roll and do the same for me.

Let me know.

Taylor

Taylor said...

Awesome awesome. I'll add you right now. Can you change my anchor text to just: blogging tips

that'd be great. what would you like your anchor text to be?

Sammy Feliciano said...

Hi bro, i have suggestion i think it could be much better if you put some screen shots.

Thanks

divxvid said...

Thank you so much for this!!!

Excellent!!!! (Works perfect with IE 7(not in ie6)and firefox.In opera appears good but grows the the width of the page!?!?
Working great...I reccoment it fot all bloggers!
Thanks again!!!
Take a look here:
http://releasethis.blogspot.com/

I had some problems (how to center the nav bar).I solve it adding more buttons to take all the width of the bar (lol)....(see ,i am an amateur about codes)

If you can tell me how to add some code for this and the other little problem (opera appearance)i'll be gratefull..

Many Thanks again......

Rethnaraj Rambabu said...

hi nitesh. i'm currently working on a template for my blog. i used your method to do drop-down menu for my blog. but, the drop down menu is clashing up with my menu

Nitesh Kothari said...

please give me the link to your blog..so taht i can the prob..

technoraX said...

nitesh,
this is the link for my blog.

http://technorax.blogspot.com



rethnaraj

Rethnaraj Rambabu ( technorax) said...

nitesh,

i'm rethnaraj, the one asked for your assistance on the horizontal menu. my sub menu clashes with the menu in navbar on mouse over. how to lower the position of the submenu?

take a look at the menu in my blog.

Technorax.blogspot.com

Vecini la bloc said...

Hi, it's working pretty well. Thanks for the post. I have a question. Why can't I change the size of the text? I tried everythig, I think. Please help!

Nitesh Kothari said...

hi just make a change to this css property "#nav li a" change the font size here

vecini la bloc said...

Thank you for the quick answer. It worked. Have you any news about a newer or better version?

Nitesh Kothari said...

@vecini: as of now i dont haveone...because i did not get time to do it.. but soon ill do it.. you can subscribe to my feeds for next updates via email

vecini la bloc said...

One more thing please. How can I align menu to the center of the page, verticali? Thanks

Steve said...

Thanks for the nice information.

Could I know how to add the down arrow picture into the menu so it's look better.

You have it on top of this blog.

Post a Comment

Thank you for commenting at NiteshKothari.com. I follow "U comment I comment" movement. All the comment are dofollow. Please do not spam or leave meaningless or short comments. I expect you to leave me meaningful, relative and genuine comments. Thank you.