How do I center my menu?

10 replies
  • WEB DESIGN
  • |
Hi,

I'm very new with css, and created a menu using this guide:
CSS horizontal menu - Online Training and Tutorials

However, the menu is at the left on my screen and I would like to center it.
Can you help me with how I can do that?
I've tried to put it in a table, but that creates some other issues.

Thanks.

Best regards,
Thomas
#center #menu
  • Profile picture of the author Harrison Ortega
    Hi Thomas, you'll need to set a fixed width to the ul class and then set the margin left and right to "auto". If you post the URL to your site, I can tell you the exact changes you need.

    basically it will look like this code
    Code:
    ul{
        list-style-type:none;
        width: 960px; /* replace 960 with the desired width */
        margin-right: auto;
        margin-left: auto;
    }
    Harrison
    Signature
    NJ web design / NJ Web Designer. MY Wordpress portfolio. 10 years of HTML/CSS - 6 years developing professional Wordpress websites. Currently not available for services.
    {{ DiscussionBoard.errors[2635659].message }}
  • Profile picture of the author ThomasTe
    Thanks, Harrison, just sent you a pm.

    Best regards,
    Thomas
    {{ DiscussionBoard.errors[2635819].message }}
    • Profile picture of the author csmcmanus
      try putting your code into a <div> and then margin auto both sides of the div
      that might help
      {{ DiscussionBoard.errors[2643030].message }}
  • Profile picture of the author ThomasTe
    Thanks.

    Actually I solved it by using mouse over on a table instead.

    Best regards,
    Thomas
    {{ DiscussionBoard.errors[2656236].message }}
    • Profile picture of the author seoref
      using <div> is the best option to center the menu...
      {{ DiscussionBoard.errors[2661381].message }}
    • Profile picture of the author RichardHK
      Originally Posted by ThomasTe View Post

      Actually I solved it by using mouse over on a table instead.
      Yuck! Tables are for data Thomas, not formatting. Use divs as advised sir!
      Signature

      Richard, Hong Kong
      Business Consulting

      {{ DiscussionBoard.errors[2662041].message }}
      • Profile picture of the author SmartWeb
        Best way to center any HTML code is to you
        <DIV align="center"> your code or html here </DIV>
        {{ DiscussionBoard.errors[2662359].message }}
  • Profile picture of the author ThomasTe
    Ha ha, thanks, Richard.

    And thanks guys. Everything works now.

    Best regards,
    Thomas
    {{ DiscussionBoard.errors[2665861].message }}
  • Hi to all i want to place ads on submit button on my web site directory i am trying to do it but not can any one help me out?
    {{ DiscussionBoard.errors[2666483].message }}
    • Profile picture of the author digitalfiz
      be carefull using a :hover css attribute on anything other then <a> tags because browsers like IE don't recognize them and ignore them. If your using the javascript onmouseover="" then it should work fine and ignore me post
      Signature
      My Blog | PHP is my Kung Fu!
      {{ DiscussionBoard.errors[2667174].message }}

Trending Topics