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.
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.
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.
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.
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;}
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With