Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do I align bootstrap tabs in the center?

I have tabs like these:

<ul class="nav nav-tabs ">
    <li class="active">
        <a href="#tab_default_1" data-toggle="tab">
            Tab 1
        </a>
    </li>
    <li>
        <a href="#tab_default_2" data-toggle="tab">
            Tab 2
        </a>
    </li>
    <li>
        <a href="#tab_default_3" data-toggle="tab">
            Tab 3
        </a>
    </li>
</ul>

But instead of having them on the left, I'd like them in the center. I tried text-align:center; and even setting margin-left:0 and margin-right:0 but neither is working. What's the easiest way to do this without re-writing the whole code?

Here's a jsFiddle:

http://jsfiddle.net/j751b1mb/

like image 895
user1227914 Avatar asked Aug 11 '15 12:08

user1227914


2 Answers

.nav-tabs > li {
    float:none;
    display:inline-block;
    zoom:1;
}

.nav-tabs {
    text-align:center;
}

http://jsfiddle.net/j751b1mb/4/

like image 92
Vishnu Avatar answered Sep 29 '22 18:09

Vishnu


In Bootstrap 4:

<ul class="nav nav-tabs justify-content-center">
like image 43
user2962393 Avatar answered Sep 29 '22 18:09

user2962393