Twitter Bootstrap: Center Pills

前端 未结 7 822
广开言路
广开言路 2020-12-02 11:09

My question is how you can center the pills?

I\'ve tried to add center block around and also to change the float:left to float:center but n

7条回答
  •  不知归路
    2020-12-02 11:42

    This has gotten much simpler! You just need to use the text-center class on the container, and apply display:inline-block to the ul. Just make sure you have a line break or paragraph tag separating the nav from any other elements within the container.

    Done! 2 class additions, 1 line of CSS (don't modify the bootstrap css file!).

    HTML:

    
    

    CSS:

    .center-pills { display: inline-block; }
    


    Edit 2015: As Artur Beljajev has brought up, Flexbox support is now common enough that you may want to use that instead:

    .center-pills {
        display: flex;
        justify-content: center;
    }
    

提交回复
热议问题