Use offset
classes provided by Bootstrap
:
<div class="container">
<div class="row">
<div class="col-xs-12 col-sm-6 col-sm-offset-3 col-md-8 col-md-offset-0">
<div class="wrapper">
<h2>Left column</h2>
</div>
</div>
<div class="col-xs-6 col-xs-offset-3 col-md-4 col-md-offset-0">
<div class="wrapper">
<h2>Right column</h2>
</div>
</div>
</div>
</div>
Explanation:
First of all in your second column when you use col-xs-6 and do not specify col-sm-* it means that this is also col-sm-6:
<div class="col-xs-6"></div>
<div class="col-xs-6 col-sm-6"></div>
This two lines of code are the same (it is better to use first one). The same goes for offset classes (if you specify col-xs-offset-3
and do not specify col-sm-offset-* it means that this is also col-sm-offset-3
).
In bootstrap you have 12 columns. If you want to center col-sm-6
you have to offset this by 3 columns (col-sm-offset-3
3+6+3).
I had to specify offsets to 0 in md columns because I had to overwrite col-sm-offset-3
. If I would not done that, it would have been col-md-offset-3
.