How to create centered main menu

Events happening in the community are now at Drupal community events on www.drupal.org.
arnemaine's picture

I am trying to create a centered main menu in my Omega sub-theme. I've looked at various CSS ideas, but can't get anything to work. Here's one very simple idea that seems like a great approach, but I can't seem to get it to work. Looking at the CSS in Firebug, I don't see any reason why it shouldn't. But I assume there is either some CSS in the framework that I need to override or that I have missed something, or need to use a new approach:

http://csswizardry.com/2011/01/create-a-centred-horizontal-navigation/

Here's what I have so far on my dev site. It may be changing, but should give people an idea of what I have:

http://dev.dianalogan.com/

Please note: I'm only trying to implement this for the narrow, normal and wide layouts. My mobile phone layout uses a very different main menu design. Right now I'm working on the narrow stylesheet, where I've overridden the global main menu styles. I haven't put together the default stylesheet, which is for my IE8 and older non-responsive layout.

Any suggestions?

Comments

Interesting technique

rlhawk's picture

That's a good technique to know about. To get it working in your situation, you should add "display: block" to the #main-menu CSS.

ul needs to be a block...

mikeker's picture

In order for text-align: center to work, the item with that style needs to be a block-level element. Your code for the main menu ul element has the class "inline" attached to it, which sets display: inline.

Two possible fixes:

  1. Figure out which Omega theme setting turns on inline for the main menu. (Sorry, not enough experience with Omega to answer that myself...)
  2. add some CSS: #main-menu { display: block; }

Hope that helps.

Thanks!

arnemaine's picture

Well that was a simple fix! Thank you both. All I needed to do was add the #main-menu {display:block} style.

The ul.inline and ul.links.inline from Omega was adding the #main-menu {display:inline} style. I also hadn't realized it needed to have the block display.

Thank you both. Turned a frustrating afternoon into a good one.

I do like the work by the fellow who posted the CSS for the centered menu. Just discovered his work He has some other resource sites that look very helpful as well:

http://csswizardry.com/resources/

Omega Framework

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: