Bob
Bob

Reputation: 10795

Twitter Bootstrap center elements

I am looking for Twitter Bootstrap examples and do not understand how all elements in this example are centered? Using what tag or style?

Upvotes: 0

Views: 96

Answers (2)

DivineChef
DivineChef

Reputation: 1221

Check out the helper classes in bootstrap here

Center content blocks Set an element to display: block and center via margin. Available as a mixin and class.

<div class="center-block">...</div>

    // Classes
    .center-block {
     display: block;
     margin-left: auto;
     margin-right: auto;
 }

 // Usage as mixins
.element {
  .center-block();
}

Upvotes: 0

Aristona
Aristona

Reputation: 9341

It is because .container div is centered using auto margins.

.container {
    margin-right: auto;
    margin-left: auto;
}

Also .jumbotron has

text-align: center;

attribute which centers the the child 'Sign up' button.

Upvotes: 2

Related Questions