css - How to center navigation bar in UL? -


tried display: inline-block; Text align: center; And there are so many things from the internet, but nothing helps.

  #nav {width: 100%; Swim left; Margin: 0 0 3em 0; Padding: 0; List style: none; Background color: # C9C9C9; Border bottom: 5px solid #ddd; Border-top: 1px solid # ccc; } # Nav li {list-style: none; Swim left; } # Nav li a {display: block; Padding: 5px 5px; Font size: 13px; Text-decoration: None; Color: # 000; Border-right: 1px solid #ccc; } # Nav li a: hover {color: #fff; Background-color: # 000; -max-boundary-radius: 3px; -Vibit-boundary-radius: 3px; -khtml-boundary-radius: 3px; Boundary-radius: 3px; }   

HTML:

  & lt; Ul id = "nav" & gt; & Lt ;? Php wp_nav_menu ('menu = header_menu and container = false'); ? & Gt; & Lt; Div class = "clear" & gt; & Lt; / Div & gt; & Lt; / Ul & gt;   

It looks like:

... and I do not know how to focus it.

The origin is:

  ul {margin: 0; Padding: 0; List-style-type: none; Text-align: center; } Li {Display: Inline-Block;   

Note if

  • gt; Floats, you lose :)

    Then, if you need to go into UL with the width of the fluid: one step higher on html.

      nav {text-align: center; } Nav ul {margin: 0; Padding: 0; Display: inline-block; List style: none; Background color: # C9C9C9; Border bottom: 5px solid #ddd; Border-top: 1px solid # ccc; } Nav li {display: inline-block; } Nav li a {display: block; Padding: 5px 5px; Font size: 13px; Text-decoration: None; Color: # 000; Border-right: 1px solid #ccc; } # Nav li a: hover {color: #fff; Background-color: # 000; -max-boundary-radius: 3px; -Vibit-boundary-radius: 3px; -khtml-boundary-radius: 3px; Boundary-radius: 3px; }    

  • Comments

    Popular posts from this blog

    excel vba - How to delete Solver(SOLVER.XLAM) code -

    c# - Add Image in a stackpanel based on textbox input -

    java - Reaching JTextField in a DocumentListener -