I’m using twitter bootstrap to create togglable tabs. Here is the css I’m using:
<div class="container">
<ul class="nav nav-tabs">
<li><a href="#home" data-toggle="tab">Home</a></li>
<li><a href="#profile" data-toggle="tab">Profile</a></li>
<li><a href="#messages" data-toggle="tab">Messages</a></li>
<li><a href="#settings" data-toggle="tab">Settings</a></li>
</ul>
</div>
This html displays the tabs correctly, but pulled to the left (which is what is supposed to happen). I’ve tried tinkering with the CSS to get the tabs to center on the page, but no luck yet. I thought someone with more css experience would know how to do this.
As a note, there is another question about centering nav pills, which I tried, but it didn’t work with just plain nav tabs.
Thanks.
nav-tabslist items are automatically floated to the left by the bootstrap so you have to reset that and instead display them asinline-block, and to center menu items we have to add the attribute oftext-align:centerto the container, like so:CSS
Demo: http://jsfiddle.net/U8HGz/2/show/
Edit here: http://jsfiddle.net/U8HGz/2/
Edit: patched version that works in IE7+ provided by user @My Head Hurts down in the comments below.
Demo: http://jsfiddle.net/U8HGz/3/show/
Edit here: http://jsfiddle.net/U8HGz/3/