Forum Moderators: not2easy

Message Too Old, No Replies

Problems Centering Horizontal CSS Menu

Center Horizontal CSS Menu

         

tim carpenter

4:08 pm on Mar 20, 2009 (gmt 0)

10+ Year Member



I've going crazy trying to get a CSS Menu to center horizontally. I've searched for the solution on web. I've implemented what looks to be the most common answer, set margin to 0 auto for the <ul> tag. Still no luck.

I bring the nav in via a php include to keep menu maintenance simpler.

I'm assuming I have some other bad code that is interfering. Can anyone help?

Here is a test page with the menu:

<snip>

Thanks in advance for your help!

[edited by: swa66 at 2:20 am (utc) on Mar. 21, 2009]
[edit reason] No personal links please see ToS. [/edit]

swa66

3:19 am on Mar 21, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I guess your <ul> is still set as display:block and has not been given a width, hence it'll take up all available with and giving auto margins will no t achive anything (they'll both be 0)

A width might help, but it would imply a need for knowing the width.

If your <li>s are inline (and not floated), a text-align:center on the <ul> would work.

Just as an example of something I posted a while back:
[webmasterworld.com...]

uses centering, unknown number of item and width per item, and sliding doors decoration ...