I'm trying to reorder the columns on my website via Bootstrap's method of reordering columns depending on the screen size which works fine for most of the responsive layouts I'm testing apart from 1.

The layout having problems is the Tablet Landscape Layout (1024 x 768) which displays like this:

Tablet Landscape

Every other screen displays the blue div and the right div either with the red div on top if the screen is too small or on the right with the blue div aligning itself exactly next to it if the screen is large enough.

This is the code I'm using right now:

<div class="container">
    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 col-xl-12">
	    <div class="row clearfix">
		    <div class="col-xs-12 col-sm-12 col-md-push-8 col-md-4 col-lg-push-8 col-lg-4 col-xl-push-8 col-xl-4" style="background: red">
			    Basket
		    </div>
		    <div class="col-xs-12 col-sm-12 col-md-pull-8 col-md-8 col-lg-pull-4 col-lg-8 col-xl-pull-8 col-xl-8" style="background: blue">
			    News
		    </div>
	    </div>
    </div>
</div>

Does anyone know why the blue div is so far to the right on the Tablet Landscape layout rather than touching the red div like it should?

Some general markup issues:

  • First of all, there's no col-xl-*, so you can get rid of those.
  • Secondly, you don't need col-xs-12, since the default is for it take up the whole width unless otherwise specified.
  • Third, Bootstrap is mobile first, so larger sizes will override the existing smaller sizes, meaning if you don't intend on changing something, there's no need to specify the larger size again.

The actual issue is that col-*-pull-* is relative to where the element would be placed. Bear in mind, you haven't changed anything in the document flow. So the elements are positioned normally and then phase shifted with left or right. Since the blue container would normally start 4 columns over, you only need to pull it back by 4 columns, instead of 8.

The whole thing can be rewritten like this:

<!-- begin snippet: js hide: false --> <!-- language: lang-css -->
.red  { background: red  }
.blue { background: blue }
<!-- language: lang-html -->
<link href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.2/css/bootstrap.css" rel="stylesheet"/>

<div class="container">
  <div class="row ">
    <div class="col-md-4 col-md-push-8 red"> Basket </div>
    <div class="col-md-8 col-md-pull-4 blue"> News </div>
  </div>
</div>
<!-- end snippet -->