For “sm” and smaller I want the divs to display as:
[ A ]
[ B ]
[ C ]
[ D ]
[ E ]
[ F ]
For “md” and bigger I want the divs to display as:
[ A ] [ D ]
[ B ] [ E ]
[ C ] [ F ]
where A is aligned with D, B is aligned with E, C is aligned with F, etc.
Is this possible with Bootstrap?
I realize I could do:
<div class="col-md-6">
<div id="A"></div>
<div id="B"></div>
<div id="C"></div>
</div>
<div class="col-md-6">
<div id="D"></div>
<div id="E"></div>
<div id="F"></div>
</div>
…but this doesn’t ensure that B is aligned with E, e.g. when A is taller than D.
2
Answers
just add
col-xs-12
(this will work in extra small and small devices) to currentcol-md-6
But
if you want to have them aligned by height (aka equal height), then you need to have them in the same parent, otherwise you can’t AFAIK, and using
clear:left
at each odd number or(2n+1)
Or
using
to have the visual effect (i.e – when using
border
)Note
If you don’t like how they are sorted, you can use
order
fromflexbox
to change their order.so here is a example with the
order
already (and a simpler version withclear:left
only)`
You actually got it right.
Make sure each div the the same height for them to line up accordingly.