[Solved] Centering the CSS Menu Horizontal

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
TJINAK
Forum Members
Forum Members
Posts: 136
Joined: Wed Feb 22, 2006 1:01 am

[Solved] Centering the CSS Menu Horizontal

Post by TJINAK »

Hello Everyone,

After reading the forums and trying some of the suggestions I still can't get this menu to center.

Take a look here at what I'm doing please:

http://www.dev.ridesalaska.org/

I've seemed to get IE to play correctly with this:

Code: Select all

#menuwrapper { 
   /* Fix for Opera 8 */ 
   /*   overflow: hidden;  */ 
   background-color: #ECECEC;
   width: 95%;
   margin: auto;
But it doesn't work with FireFox - and my client is using Firefox.

Please advise if possible.

TJ
Last edited by TJINAK on Wed Nov 07, 2007 2:50 am, edited 1 time in total.
User avatar
lollipop27
Forum Members
Forum Members
Posts: 237
Joined: Wed Sep 12, 2007 4:09 pm

Re: Centering the CSS Menu Horizontal

Post by lollipop27 »

why dont you tell the #menuwrapper: text-align: center?
User avatar
lollipop27
Forum Members
Forum Members
Posts: 237
Joined: Wed Sep 12, 2007 4:09 pm

Re: Centering the CSS Menu Horizontal

Post by lollipop27 »

no wrong, give the menuwrapper the width: 780px;

:)
User avatar
kermit
Power Poster
Power Poster
Posts: 693
Joined: Thu Jan 26, 2006 11:46 am

Re: Centering the CSS Menu Horizontal

Post by kermit »

if that top menu is only going to be root level items (no dropdowns); then the absolute easiest thing to do is dump the complicated default menu styles and style your own from scratch; perhaps using minimal_template.tpl as the basis for your menu template... might end up with something like this :

Code: Select all

#topmenu{padding:.25em 0;text-align:center;width:100%}
#topmenu ul{list-style:none}
#topmenu ul li{display:inline;margin:0 .5em}
#topmenu a{padding:.25em .5em}
#topmenu a.current,#topmenu a.activeparent{font-weight:700}
#topmenu a:hover{text-decoration:none}
(note: i stripped the colors and what-not out of this working example)
eternity (n); 1. infinite time, 2. a seemingly long or endless time, 3. the length of time it takes a frozen pizza to cook when you're starving.
4,930,000,000 (n); 1. a very large number, 2. the approximate world population in 1986 when Microsoft Corp issued its IPO. 3. Microsoft's net profit (USD) for the quarter (3 months) ending 31 March 2007.
CMSMS migration and setup services | Hosting with CMSMS installed and ready to go | PM me for Info
TJINAK
Forum Members
Forum Members
Posts: 136
Joined: Wed Feb 22, 2006 1:01 am

Re: Centering the CSS Menu Horizontal

Post by TJINAK »

After having a cup of coffee my brain woke back up and I remembered this little formula:

CSS Width = width + margins + padding

No need for a calculator here.  My page width is 800px.

Minor changes to my stylesheet:

Code: Select all

#menuwrapper { 
   width: 750px;
   margin: auto;
   padding: 0 0 0 50px;
Then a little padding for my top level links, (spreading out the fun!):

Code: Select all

#primary-nav a { 
   display: block; 
   margin: 0px; 
   padding: 5px 12px 0px 12px; 
   text-decoration: none; 
   font-weight: bold;
   color: #672614;
Note the 0 padding on the primary-nav a class becuase if I did add padding I could not get to the sub menus due to white space.

After reading Dan Cederholms "Bulletproof Web Design" things are maybe starting to sink in.

Now to read his other book and learn what I should have learned from the begging....simple, clean, html markup.

Thanks for reading.

TJ
User avatar
designhut
Forum Members
Forum Members
Posts: 71
Joined: Sat Jul 21, 2007 10:31 am

Re: [Solved] Centering the CSS Menu Horizontal

Post by designhut »

Magic! Thx for posting!  :D :D
Post Reply

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