In general you want to group elements that stack, but in your case B
and A
can't be grouped since Logo
needs to be inserted between them in one case. You have two options
Without using JS, I think this is going to be your best option. fiddle here
<div class="container">
<div class="logo col-sm-4 col-xs-6 col-sm-push-4">Logo<br/>Logo</div>
<div class="contentB col-sm-4 col-xs-6 col-sm-pull-4">B</div>
<div class="contentA col-sm-4 col-xs-6 col-xs-offset-6 col-sm-offset-0">A</div>
</div>
The idea is to use the rollover property of rows to push A
down in the xs case. I also use the push/pull classes to rearrange the divs in the sm case. However, the problem here is if Logo
is taller than B
. Since everything is on the same grid, A
aligns with the bottom of the bigger element, giving us blankspace between Logo
and B
. This really doesn't have any solution with pure Bootstrap CSS. (Maybe someone can correct me)
Instead, I suggest you use JS to move the div when the window resizes. fiddle here
<div class="container">
<div id="column1" class="row col-xs-6 col-sm-8">
<div id="B" class="col-xs-12 col-sm-6">B</div>
<div id="logo" class="col-xs-12 col-sm-6">Logo<br/>Logo</div>
</div>
<div id="column2" class="row col-xs-6 col-sm-4">
<div id="A" class="col-xs-12 col-sm-12 ">A</div>
</div>
</div>
and the JS
$(function() {
$(window).resize(function() {
var w = $(window).width();
if (w < 768 && $('#column1').children().length > 1) {
$('#B').prependTo( $('#column2') );
} else if (w > 768 && $('#column2').children().length > 1) {
$('#B').prependTo( $('#column1') );
}
});
});
EDIT:
Reference the bootstrap grid docs for info on the push/pull/offset classes.