Search code examples
htmlcssalignmentcenter

<ul> Menu won't center


I have a menu on wordpress that I'm trying to center, but it wont center itself. If I put auto on margin it doesn't do anything but when a fixed number is set, it does, but it doesn't align perfectly unlike using auto.

CSS

.menu {
    width:auto;
    float: left;
    display:block;
}

#navcontainer {
    display:inline;
    padding:0px;
    margin: 0px; /*-8px 0 0 10px;*/
    list-style:none;
    position:relative;
    z-index:1;
    float:left;
    height: 20px;
    width: 100%;
}

HTML

<section class="twelve columns text-center" style="background: transparent;">
<div class="menuimg">
<img src="http://fabioide.com/frederiksminde/wp-content/uploads/2014/10/menu.jpg">
</div>
<div id="navcontainer">
<?php wp_nav_menu( array( 'sort_column' => 'menu_order', 'container' => false, 'theme_location' => 'header-menu' ) ); ?></div>
</section> 

Solution

  • HI now replace two css in your style sheet

    #navcontainer {
    float: none;
    display: block;
    list-style: none;
    position: relative;
    z-index: 1;
    height: 20px;
    width: 100%;
    text-align: center;
    }
    
    .menu {
    width: auto;
    float: none;
    display: inline-block;
    text-align: left;
    }
    

    enter image description here