skeleton-css-boilerplate

Centering navigation bar


I am having trouble centering my navigation bar, I have tried display:inline-block and then align center like most posts suggest but it doesn't seem to be working.

HTML:

<!--Navigation-->
<div class="band navigation">
    <nav class="container primary">
        <div class="sixteen columns">
            <ul>
                <li><a href="index.html">Home</a></li>
                <li><a href="#">About Us</a></li>
                <li><a href="#">Projects</a></li>
                <li><a href="#">Contact Us</a></li>
            </ul>
        </div>
    </nav>
</div>

CSS:

nav.primary{
  display: table;
  margin: 0 auto;
}

nav.primary ul, nav.primary ul li {
  margin: 0px;
}

nav.primary select {
  display: none;
  width:  100%;
  height: 28px;
  margin: 21px 0;
}

nav.primary ul li {
  display: inline;
  float: left;
  position: relative;
}

nav.primary ul li a {
  display: inline-block;
  line-height: 49px;
  padding:  0 14px;
  color: white;
  text-transform: uppercase;
  text-decoration: none;
  font-weight: bold;
  letter-spacing: 0.08em;
  background: ##999999;
}

nav.primary ul li a:hover {
  background: #2ecc71;
  cursor: pointer;
}

Solution

  • Ok finally got it:

    nav.primary ul li {
    display: inline;
    float: left; <---
    position: relative;
    

    Remove the float: left;

    Since the navigation is the full width of the containing div, there is no need to mess with floats, the list items will line up with just display: inline;