I’ve created a very simple plugin for creating and adding dropdown menus to your page. In this simple step-by-step tutorial i will try to explain how to create your own theme with simple css edits. All you need to do is to follow those simple steps and you will have one great css-only dropdown with colors you like!
- First we need to set default theme to NONE for the dropdown menu. You can do that from the “Dropdown Menu” item under your WordPress Settings.

- Then open your theme stylesheet from Appearance -> Editor. Make sure your current theme is selected. Select Stylesheet from Styles and scroll to the bottom of the file. You can add a reminder using /* and */ slashes as in the image. We will create our css rules after this line.

- Dropdown menu css tree is defined in following way.
.shailan-dropdown-menu -> main container of the menu (div element) ul.dropdown -> top list ul.dropdown li -> top list item + sub items (refers to <li> elements under <ul>) ul.dropdown li a -> menu links ul.dropdown li ul -> sub lists
- First we add a background image to top level using the .shailan-dropdown-menu class:
.shailan-dropdown-menu { background: #000 url("your-image-here.jpg") top right repeat; }#000 defines background color to be black. Look here for more html color codes. Your background image should be in your theme directory. Otherwise you should put a full url like “http://shailan.com/sample.jpg”. Other k-words define positioning and repeating of background. Visit here for more info on background.
- Second most important thing on the menu style is the link style:
.shailan-dropdown-menu ul.dropdown li a { padding: 5px 15px; font-size: 1em; color: #fff; }Here we defined top-bottom (5px) and right-left (15px) padding values. And we set color to white.
- Now let’s define the mouse over style for the links:
.shailan-dropdown-menu ul.dropdown li a:hover { font-style: italic; background-color: #fff; color: #333; }This rule defines that when we move mouse over (hover) a link (< a > element in html) it will have white (#fff) background color and text will be a dark gray (#333). Text will become italic also.
- One more additional style will be dropdown background:
.shailan-dropdown-menu ul.dropdown li ul{ width:auto; background: #333; background: url(images/opacity.png); border-radius: 4px; -moz-border-radius: 4px; -webkit-border-radius: 4px; -khtml-border-radius: 4px; }This is a rather complex rule. This rule defines background for the dropdown menu’s when you move over a link. Here we set it to have a gray(#333) background. Then we put a background image to it. Transparent pixels don’t work in older Internet Explorer browsers. You should get Google chrome really if you are still using IE. Here we also add corner radius which is also not supported by Internet Explorer.
- The last style rule comes for the current page or category link. If you want current page or category seem different than other links add following:
.shailan-dropdown-menu ul.dropdown li.current_page_item>a, .shailan-dropdown-menu ul.dropdown li.current-cat>a, .shailan-dropdown-menu ul.dropdown li.current-cat>a:hover, .shailan-dropdown-menu ul.dropdown li.current_page_item>a:hover{ color: #333; background: white; }This will make your current page/category have a white background with dark gray text.
- Now to wrap it up here is the final code:
/* MY-DROPDOWN-STYLES */ .shailan-dropdown-menu { background: #000 url("your-image-here.jpg") top right repeat; } .shailan-dropdown-menu ul.dropdown li a { padding: 5px 15px; font-size: 1em; color: #fff; } .shailan-dropdown-menu ul.dropdown li a:hover { font-style: italic; background-color: #fff; color: #333; } .shailan-dropdown-menu ul.dropdown li ul{ width:auto; background: #333; background: url(images/opacity.png); border-radius: 4px; -moz-border-radius: 4px; -webkit-border-radius: 4px; -khtml-border-radius: 4px; } .shailan-dropdown-menu ul.dropdown li.current_page_item>a, .shailan-dropdown-menu ul.dropdown li.current-cat>a, .shailan-dropdown-menu ul.dropdown li.current-cat>a:hover, .shailan-dropdown-menu ul.dropdown li.current_page_item>a:hover{ color: #333; background: white; }And we are done!
Now that you know how to create a simple dropdown menu style, you can download the widget and start building your own menu theme!


16 Comments
Man, GOod Job
Thanks Mohammed.
Can I set the width on the drop downs? They go all the way to the edge of the page.
Yes you can set its width using:
.shailan-dropdown-menu{width:800px;}in your theme stylesheet.
I just installed the dropdownmenu thing and fiddled around with the code a bit but…
Where do I change the font size and the font colour? I have no idea when it comes to code, I… well… have really no idea.
You can change the font and font size using the code below:
.shailan-dropdown-menu ul.dropdown{font:"Segoe UI",Calibri,"Myriad Pro",Myriad,"Trebuchet MS",Helvetica,Arial,sans-serif; font-size: 10px;}If it doesn’t change it try using an ID override like below:
#header ul.dropdown{..font css here..}I will add an option for this in the next version.
I’m trying to figure out why I have a double bubble on my menus. When you hover over a menu item it is duplicated in a grey bubble.
It seems like it’s the title attribute but I have that unchecked in Settings, Dropdown Menu. When I check it the double bubble goes away but I loose all my css that I had set up in the menus.
Any thoughts? I don’t know code but I’m trying my best to figure it out…
Thanks for your help, and the great plug-in!
Hi, thanks for the great plug in, just one question:
Is there a way to make a parent page not link to anywhere? For example, under “Services” I have Child Pages 1, 2 & 3 – I don’t want the parent page “Services” to be clickable – but for those without drop downs, they should remain clickable. Thanks for any input or thoughts…
Hm, I figured it out using this plug-in http://wordpress.org/extend/plugins/page-lists-plus/
It works! So disregard… Thanks again
Thanks for the tip. I added it to FAQ.
wow, Fantastic
my blog has header image, the menu is located over it.
how can I move it down some pixel?
I moved the whole menu beneath my header by placing it after the header image in the header.php file of my theme. That’s not what you’re talking about is it? You want the menus to appear underneath your header image???
yes, underneath my header image,
in fact I want to move it vertically,
move it x Pixel down, it’s too top for me.
Hello Omid,
You can add a top margin to the menu. Here is how to do it:
.shailan-dropdown-menu{margin-top:20px;}This will add a 20px margin to top of menu. For absolute positioning you may also try:
.shailan-dropdown-menu{ position:relative; top:20px; }This way menu will come in front of other objects.
Hope that helps.
Hi there. Great plugin ! I tried adding the custom code as given in the tutorial but it’s not working properly. I guess the Dreamline template I am using on WP is interfering with it? I’m a CSS newbie but basicallly I want to keep the nav bar button styling that the Dreamline template creates, but the dropdown menus should be different styling. Currently the dropdown buttons that your plug in creates are the same as the nav bar buttons but as they are tabs it doesn’t look very good. That’s why I tried adding the custom CSS code to try and override the problem but it’s not working. Where do I need to start looking to get this to work? Many thanks in advance. Best regards, Paul
Can you do me a favor and tell me exactly where you place the code for your menu bar at the top of the wp-theme Atahualpa. I can get the widget for the side bars, but I have no exp w/ css, php, flash, just html. I like the style and layout of your plugin, but I need a little assistance learning how to install them.
Thanks for your help!
One Trackback
Pingback: Wordpress dropdown menu widget | Shailan