How do I center the next navigation bar in Boostrap?

I have a navigation bar that looks like this:

<nav class="navbar navbar-default">
<div class="container-fluid">
        <ul class="nav navbar-nav">
            <li class="active"><a href="#">Hello</a></li>
            <li><a href="#">About Me</a></li>
            <li><a href="#">Portfolio</a></li>
            <li><a href="#">Blog</a></li>
            <li><a href="#">Contact</a></li>
        </ul>
</div>

I just wanted to center the items on the list. I tried:

.navbar-default {
  width: 100%;
  text-align: center;
}

But no luck.

+4
source share
2 answers

which should help you margin:0 auto;

+3
source

You can set margin:0 auto;the navigation style as another answer suggests, or you can also add the bootstrap class to it container, which basically does the same for you.

+1
source

Source: https://habr.com/ru/post/1620931/


All Articles