Posted on July 9, 2008 in Drupal CMS
On a couple of websites I've built I've wanted to change the default Drupal menu into something that closely resembles buttons.
For example:

This is easy to do using CSS.
The menus in Drupal are formatted as unordered lists using <ul> and <li>, with some funky CSS included in by default to give the standard bullets and arrows.
To create a blocky, CSS button look we need to overwrite the default CSS with some of our own. In theory it's not that difficult, but it took me a while of playing around to figure out what CSS rules needed to be overwritten.
I start all my themes with Zen, so I'm not sure if this CSS will work by default with other themes - give it a try.
In your theme's CSS file, add the code:
/* menu buttons */
.block-menu ul.menu,
.block-menu li.leaf,
.block-menu li.collapsed,
.block-menu li,
.block-menu .item-list ul,
.block-menu .item-list ul li {
list-style: none;
list-style-image: none;
list-style-type: none;
margin: 0;
padding: 0;
}
.block-menu .block-inner a,
.block-menu .block-inner a:visited {
color: #333;
text-decoration: none;
display: block;
/*width: 168px;*/
padding: 1px 6px;
margin: 2px 0;
border-width: 1px 1px 1px 8px;
border-style: solid;
border-color: #DDD;
font-size: 0.9em;
}
.block-menu .block-inner a:hover {
color: #FFFFFF;
background-color: #880a0b;
border-color: #880a0b;
}
You will need to adjust the '.block-menu' part of the selector to target your particular menu. Then fill in your own colours, mess around with the margins and padding to suit your site and away you go!

Brandon
12 months ago
I love the menu you created. I'd like to implement that on my drupal page, but I just can't figure it out. I'm using the Inove theme (found here: http://drupal.org/project/inove)
I would be SO appreciative if you could help me figure this out.
Thank you!
OkonX
1 year ago
There is a module called Nice Menus available. It looks just like this and is very easy to implement.
James
1 year ago
Hi OkonX
Are you referring to http://drupal.org/project/nice_menus ? It does make menus look like this but it's mainly used for dropdowns or drop-sideways menus - works well though, you're right.
karel
1 year ago
hello,
please help me: I can't get the menu working, it should work because the bullets are not visible any more for the primary menu.. but I have nog boxes or bleu color around my menu..
(the grey box is also not showing up)
I should like to work with this menu.. can you help me
karel
James
1 year ago
Hi Karel,
I'm not sure if I understand exactly what you're asking. By default, the CSS for the menus does call in some images to show parent menu items and open and closed states etc. If you want to replace these images you can simply put new images in with the same filenames - the CSS will find the new images instead of the old - or chage the CSS to call in the new images.
I hope you figure it out! Let me know if I can help any further.
Post new comment