Twitter Bootstrap: Center Pills

前端 未结 7 816
广开言路
广开言路 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:51

    While the answer of @minaz works for a list with a known width, i'd propose a different solution which actually works even if you change the content of the list:

    .tabs, .pills {
      text-align: center;
    }
    
    .tabs li, .pills li {
      float: none;
    }
    

    Or in SCSS:

    .tabs, .pills {
      text-align: center;
      li { float: none; }
    }
    

    This will center the text inside the list, and resets the float property for the list items so they are affected by the text-align property.

提交回复
热议问题