I am working with Twitter Bootstrap v3 and want to reorder elements responsively, using column ordering and offsetting.
This is how I would like to use my elements.
I tried the push/pull as shown in the answer by Skelly but C ends up in a new row once heights are applied: http://www.bootply.com/Q3djHYawgb#
If B can be shown first when shown in small size, then I think it makes more sense to create a row inside the right hand side column to contain A and C:
<div class="containing row">
<div class="b col-xs-12 col-md-6">Content of B</div>
<div class="ac col-xs-12 col-md-6">
<div class="row">
<div class="a col-xs-12">Content of A</div>
</div>
<div class="row">
<div class="c col-xs-12">Content of C</div>
</div>
</div>
</div>
See http://jsfiddle.net/hoodoo99/L2BE9/
The answer provided by @skelly is great starting point, but does cause some vertical alignment issues. Imagine A is a tall div, then C is vertically aligned below A.:
[A] [B]
[ ]
[C]
Also, If you want to take this a step further you may also need to consider using clearfix
blocks. For example;
<!-- Add clearfix for only the required viewport(s) -->
<div class="clearfix visible-md-block visible-lg-block"></div>
Without clearfix
md
or lg
might end up as:
[A] [B]
[C] [D]
This is particularly important if you want more than 2 elements in the final "column", or the heights of the elements start throwing other elements out of alignment.
With the clearfix
md
or lg
would be:
[A] [B]
[C]
[D]
Example fiddle: http://jsfiddle.net/L5174o8d/
I think you want to look at the push
and pull
classes...
<div class="row">
<div class="a col-xs-12 col-sm-12 col-md-6 col-lg-6 col-lg-push-6 col-md-push-6">Content of A</div>
<div class="b col-xs-12 col-sm-12 col-md-6 col-lg-6 col-lg-pull-6 col-md-pull-6">Content of B</div>
<div class="c col-xs-12 col-sm-12 col-md-6 col-lg-6 col-lg-push-6 col-md-push-6">Content of C</div>
</div>
Demo: http://bootply.com/77853
Any reason to not use more traditional methods on this, ie. floating B left and the other elements to the right?
Like if you added this to current CSS in your jsfiddle:
.b {
float: left;
width: 50%;
height: 100px;
}
.a, .c {
float: right;
width: 50%;
height: 50px;
}
See http://jsfiddle.net/E6BFk/
I'm not sure that Bootstrap's column ordering could accomplish the stacking effect, perhaps only the re-ordering... Though the documentation is pretty slim on that feature.