How do I center the twitter bootstrap tabs on the page?

前端 未结 8 2097
我寻月下人不归
我寻月下人不归 2020-12-04 07:19

I\'m using twitter bootstrap to create togglable tabs. Here is the css I\'m using:

    &
8条回答
  •  情书的邮戳
    2020-12-04 08:06

    nav-tabs list items are automatically floated to the left by the bootstrap so you have to reset that and instead display them as inline-block, and to center menu items we have to add the attribute of text-align:center to the container, like so:

    CSS

    .nav-tabs > li, .nav-pills > li {
        float:none;
        display:inline-block;
        *display:inline; /* ie7 fix */
         zoom:1; /* hasLayout ie7 trigger */
    }
    
    .nav-tabs, .nav-pills {
        text-align:center;
    }
    

    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/

提交回复
热议问题