Centering a Twitter Bootstrap button

http://stackoverflow.com/questions/8057802/html-button-close-window

If you don’t mind a bit more markup, this would work:

class="centered"> class="btn btn-large btn-primary" type="button">Submit

With the corresponding CSS rule:

.centered
{
    text-align:center;
}

I have to look at the CSS rules for the btn class, but I don’t think it specifies a width, so auto left & right margins wouldn’t work. If you added one of the span or input- rules to the button, auto margins would work, though.

Edit:

Confirmed my initial thought; the btn classes do not have a width defined, so you can’t use auto side margins. Also, as @AndrewM notes, you could simply use the text-center class instead of creating a new ruleset.

shareedit
4
Even better you could use bootstraps text-center class and not have to write any css yourself. for example

Submit

–  andrewmilson May 17 ’14 at 23:30