Alas, what you are trying to do is not possible with bootstrap, at least not the way you tried it.
Contrary to what has been suggested in another answer and contrary to what even bootstraps official docs will make you believe, .col-*-push-*
and .col-*-pull-*
will not change the order of columns, just their horizontal position, so you can't use theses classes to move a column vertically.
Fortunately there are several things you actually can do, all of them have their pros and cons:
Change the vertical position of a div with CSS
This only works, if you know the height of the elements you have to move past, in your case .d
. If you do, change your css to include the following (adjust the height to your needs):
.d {
height:50px;
}
@media(min-width:768px) {
.e {
top:-50px;
}
}
full example
Change the vertical position of a div with jQuery
If you don't know the height of .d
, you can use jQuery to determine its height and change .e
s css accordingly:
if ($(window).innerWidth() >= 768) {
$('.e').css('top', -$('.d').outerHeight());
}
full example
Again: This can be achieved without jQuery, using pure JS.
Reorder the elements using jQuery
The key here is that there will be no manual moving around of elements, but we'll actually remove an element from the DOM and insert it at a different position to actually change the order of the elements:
if ($(window).innerWidth() >= 768) {
$('.e').detach().insertAfter('.c');
}
full example
Use elements multiple times and show them based on viewport size
You can include some elements several times and add the appropriate bootstrap classes .hidden-xs
and .visible-xs-block
<div class="container">
<div class="row">
<div class="col-sm-8 a">A</div>
<div class="col-sm-4 b">B</div>
<div class="col-sm-8 c">C</div>
<div class="col-sm-4 e hidden-xs">E</div>
<div class="col-sm-8 d">D</div>
<div class="col-sm-4 e2 visible-xs-block">E</div>
</div>
</div>
full example
Might not be the best solution in regards of accessibility or search engine optimization, but if your content is static and you're only interested in how it looks on a screen, this is the easiest way.