A Full-Width Centered Navigation Top Bar - Zurb Foundation

dpaluy picture dpaluy · May 23, 2013 · Viewed 19.3k times · Source

I am using Zurb Foundation 4 and I need my top bar navigation to be centered as .large-12.columns

enter image description here

I tried the following (but it doesn't work)

<div class="row">
  <div class="large-12 columns">
      <nav class="top-bar">
        <ul class="title-area">
          ...
        </ul>

        <section class="top-bar-section">
          <ul class="left">
            <li><a href="#">Link 1</a></li>
            <li><a href="#">Link 2</a></li>
          </ul>

          <ul class="right">
            <li><a href="#">Link 3</a></li>
            <li><a href="#">Link 4</a></li>
          </ul>
        </section>
    </nav>
  </div>
</div>

Update:

I created jsFiddle based on Foundation Example If the browser size is big, the navigation width changes. But I want it to be centered fixed as main content.

Answer

Guillaume picture Guillaume · May 24, 2013

As the Foundation 4 docs saying : http://foundation.zurb.com/docs/components/top-bar.html

If you want your navigation to be set to your grid width, wrap it in div class="contain-to-grid".

So try using the following :

<div class="contain-to-grid">
    <!-- Your nav bar -->
    <nav class="top-bar">
        <ul class="title-area">
            <!-- Title area here... -->
        </ul>

        <section class="top-bar-section">
            <ul class="left">
                <!-- Title area here... -->
            </ul>
            <ul class="right">
                <!-- Title area here... -->
            </ul>
        </section>
     </nav>
</div>

Hope this helps !