Question

I need to align this navigation menu centered horizontally on the page. I would also like to reduce the size of the box the text appears in.

JSFiddle: http://jsfiddle.net/6W2qm/

HTML

<nav>
 <ul class="navigation">
    <li><a href="index.html">Home</a></li>
    <li><a href="biography.html">Biography</a></li>
    <li><a href="media.html">Media</a>
      <ul>
          <li><a href="media.html">Pictures</a></li>
          <li><a href="media.html">Videos</a></li>
     </ul>
    </li>
    <li><a href="tour.html">Tour</a></li>
    <li><a href="contact.html">Contact</a></li>
  </ul>
</nav>

CSS

nav {
    height:100px;
    list-style:none;
    text-align:center;
    width:1024px;
}

nav ul ul {
    display:none;
    padding:0;
    position:absolute;
    top:10%;
}

nav ul li:hover > ul {
    display:block;
}

nav ul {
    list-style:none;
    margin:0;
    padding:0;
    position:relative;
}

nav ul:after {
    clear:both;
    content:"";
    display:block;
}

nav ul li {
    float:left;
    width:100px;
}

nav ul li a {
    display:block;
    padding:25px 40px;
    text-decoration:none;
    width:0;
}

nav ul ul li {
    float:none;
    position:relative;
}

nav ul ul li a {
    padding:15px 40px;
}
Was it helpful?

Solution

I can't tell about the rest of your page when you only provided a small amount of the code, but this looks OK now.

JSFiddle: http://jsfiddle.net/D9z3s/

I changed the following line to 50% instead of 10% and it doesn't overlap anymore:

nav ul ul {
    padding: 0;
    position: absolute;
    top: 50%;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top