How to center buttons in Twitter Bootstrap 3?

后端 未结 14 1392
南笙
南笙 2020-11-30 17:36

I am building a form in Twitter Bootstrap but I\'m having issues with centering the button below the input in the form. I have already tried applying the center-block<

14条回答
  •  天涯浪人
    2020-11-30 18:21

    Update for Bootstrap 4:

    Wrap the button with a div set with the 'd-flex' and 'justify-content-center' utility classes to take advantage of flexbox.

    
    

    The benefit of using flexbox is being able to add additional elements/buttons on the same axis, but with their own separate alignment. It also opens up the possibility of vertical alignment with the 'align-items-start/center/end' classes, too.

    You could wrap the label and button with another div to keep them aligned with each other.

    e.g. https://codepen.io/anon/pen/BJoeRY?editors=1000

提交回复
热议问题