Centering the CSSMenu [Solved]

For discussion and questions related to CMS Specific templates and stylesheets (CSS), and themes. or layout issues. This is not a place for generic "I don't know CSS issues"
Post Reply
User avatar
Nullig
Power Poster
Power Poster
Posts: 2380
Joined: Fri Feb 02, 2007 4:31 pm

Centering the CSSMenu [Solved]

Post by Nullig »

I have changed the Navigation: CSSMenu - Horizontal style to center the menu by changing the following:

Code: Select all

#primary-nav, #primary-nav ul { 
   list-style: none;
   padding: 0px;
   width: 50%; 
   margin: 0 auto; 
}
This has caused a minor annoyance in Firefox. When I hover on the last two menu items on the right, the bottom scrollbar appears. It is particularly annoying when the page content is close to filling the browser window, as this then causes the right-hand scrollbar to appear, shifting the page content left.

Any ideas as to what I can change to affect this behavior?

Nullig
Last edited by Nullig on Sat Feb 10, 2007 11:57 pm, edited 1 time in total.
tsw
Power Poster
Power Poster
Posts: 1408
Joined: Tue Dec 13, 2005 10:50 pm

Re: Centering the CSSMenu

Post by tsw »

try wrapping the menu in a extra div with style="margin:0 auto;"

dunno if it helps, but its worth trying
User avatar
Nullig
Power Poster
Power Poster
Posts: 2380
Joined: Fri Feb 02, 2007 4:31 pm

Re: Centering the CSSMenu

Post by Nullig »

No... didn't work.

I suspect it has something to do with the menu levels and may not be easily fixed. It doesn't happen in IE, only FF.

Anyone else have any ideas?

Nullig
User avatar
Nullig
Power Poster
Power Poster
Posts: 2380
Joined: Fri Feb 02, 2007 4:31 pm

Re: Centering the CSSMenu [Solved]

Post by Nullig »

OK, I think I've solved the problem - it has to do with the 100% width in FF.

So, in my template, I added a div around the horizontal menu to preserve the background color and made the menu smaller with a wider margin.

The template changes:

Code: Select all

   <!-- Start Navigation -->
<div style="background-color: #ECECEC;width: 100%;"> <!-- Wrapped in a new div to preserve bg color -->
   <div id="menu_horiz">
      <h2 class="accessibility">Navigation</h2>
      {menu template='cssmenu.tpl' start_level='2' start_element='1.1' show_root_siblings='1'}
   <hr class="accessibility" />
   </div>
</div>                                               <!-- End of new div -->
   <!-- End Navigation -->
and the CSSMenu - Horizontal changes:

Code: Select all

#menuwrapper { 
   /* Fix for Opera 8 */ 
   /* overflow: hidden; */
   background-color: #ECECEC;
   border-bottom: 1px solid #C0C0C0;
   margin: 0 0 0 23%;   <!-- These need to be adjusted according -->
   width: 75%;          <!-- to the width of your menu -->
   text-align: left;
}
This seems to have done the trick. You have to play around with the margin percentages to get the "pseudo-centering" effect, but it eliminates the annoying horizontal scrollbar in FF popping on and off.

Nullig
Post Reply

Return to “Layout and Design (CSS & HTML)”