Search code examples
csstwitter-bootstrapflexboxbootstrap-4twitter-bootstrap-4

Order and stack 3 columns with bootstrap 4


I have this structure in bootstrap columns: enter image description here

And I want you to change to a lower resolution, be ordered as follows:enter image description here

I found how to do it with flexbox here: Flexbox: reorder and stack columns

But I can not change the entire structure of my project to flexbox, so I want to know if with bootstrap 4, it is possible to do so.

Thank you very much.

My poor test.

@import url( 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css' );

div {
  text-align: center;
  height: 60px;
}

#left {
  background: yellow;
}

#middle {
  background: blue;
}

#right {
  background: coral;
}
<div class="container">
  <div class="row">
    <div class="col-sm-3 col-md-3">
      <div id="left">COLUMN 1</div>
    </div>
    <div class="col-sm-6 col-md-6">
      <div id="middle">COLUMN 2</div>
    </div>
    <div class="col-sm-3 col-md-3">
      <div id="right">COLUMN 3</div>
    </div>
  </div>
</div>


Solution

  • You can use the Bootstrap 4 (alpha 6) utility classes to avoid the extra CSS. 1-2-3 becomes 3-2-1 on mobile.

    <div class="container">
        <div class="row">
            <div class="col-sm-8 col-md-6 push-md-3">
              <div id="middle">COLUMN 2</div>
            </div>
            <div class="col-sm-4 col-md-6">
              <div class="row">
                <div class="col-md-6 pull-md-12 flex-last flex-md-unordered">
                 <div id="left">COLUMN 1</div>
               </div>
                <div class="col-md-6">
                 <div id="right">COLUMN 3</div>
               </div>
              </div>
            </div>
        </div>
    </div>
    

    http://codeply.com/go/GIcPuzURbs