Support » Fixing WordPress » Center nav-area

  • Hello

    I’m trying to place my site’s nav-link in the center of the site. But I’m unable to do so.

    I’ve tried with theese and many more without luck.

    #access ul
    {margin-left: auto;
    margin-right:auto;
    }
    
    #access ul
    {text-align:center;
    }

    Help, please.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You’ll need to provide a link to your site if you want to get some specific help with this so people can at least see what kind of HTML/CSS framework you’re dealing with.

    Ordinarily, you’d use the margin-left and margin-right set to auto as you did in the first example, but not for the ul. You’d do it with a set of divs so that the centered element has an element of greater width to center in:

    <div id="outer-element">
      <div id="access">
        <ul>
         ...
        </ul>
      </div>
    </div>

    And your CSS would be:

    #outer-element {
      width: 100%;
    }
    
    #access {
      margin-left: auto;
      margin-right: auto;
    }

    Then, as long as #outer-element is set to some width larger than the width of the content of the “access” div (it doesn’t have to be 100%, but that ought to work), your access div should be centered.

    Thank you! I’ve fixed it now 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Center nav-area’ is closed to new replies.