Chocolate Chip multimedia | Small business website design specialists

CSS

Styling Drupal's menu items into buttons with CSS

in

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:

CSS Menus

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;
}

Fill in your own colours, mess around with the margins and padding to suit your site and away you go!

Syndicate content

Improve Your Performance Online

Sign up to our monthly newsletter for practical, meaningful advice to gain your business the competitive edge online.

 

What Clients are Saying

"You sure offer the fastest turn around time in the business! ... What a pleasure to work with you!! ... It is getting better and better all the time!! Thanks."

- Carl Ahlers, Prof Bunsen Science

"We're getting a lot of compliments on the site - everyone we've spoken to is very impressed... I can't even begin to emphasise how amazing a job you've done."

- Travis Lee, Cursions Py Ltd

"I cannot thank you enough for your professional and patient assistance with this website. The proof is there, the endless applause continues. We can only look towards a very bright future."

- John Kovacs, NMD Data

"A huge thank you!!!! It looks fantastic, love the colours you have used. Can't thank you enough for taking care of this."

- Andrea Robinson, Mphatso Children's Foundation

Click here to choose a website package for your business!