Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I center the Zurb Foundation top bar nav?

The top bar nav on my site is left aligned like this:

| Home | aveoTSD | Silent Nite          |

I would like to center the top bar nav like this:

|          Home | aveoTSD | Silent Nite          |

Center it exactly like the red bar with "Example" text.

Here is my css.

like image 201
user2343800 Avatar asked May 31 '13 22:05

user2343800


People also ask

How do I center the top navbar?

We can center the navbar using margin: auto property. It will create equal space to the left and right to align the navbar to the center horizontally. Additionally, add the width of the navbar.

How do I center text NAV?

You need to take the float:left off of both your #nav and li elements. Then add display:inline-block; to both. Next add your text-align:center to the #nav . Save this answer.

How do I center a nav bar in CSS?

Suppose you have four items in your navigation menu–you can work out the width of these and use margin:0 auto; to centre them.


2 Answers

You can do it by adding this to your CSS (and preferably removing conflicting styles):

.top-bar-section ul {display: table; margin: 0 auto;}
.top-bar-section ul li {display: table-cell;}
like image 139
ralph.m Avatar answered Sep 24 '22 20:09

ralph.m


Found this to be helpful: https://github.com/zurb/foundation/issues/1598

Set the container of the navigation to: text-align:center;

Then for the navigation itself, set the display to: display:inline-block;

Hope that helps!

like image 34
cleegp Avatar answered Sep 22 '22 20:09

cleegp