2

So here's what I have in a LG design.

    +-----+-----+
    |  A  |  B  |
    +-----+-----+
    |  C  |  D  |
    +-----+-----+

I want to reorder it in a MD design to look like this:

    +---------+---------+
    |         A         |
    +---------+---------+
    | C   |   D  |  B   |
    +-------------------+

Is there a way for me to push "B" from the first row to the second, in that position? :)

borbs
  • 177
  • 1
  • 3
  • 12

2 Answers2

3

Try something like this:

.row div {
  border: 1px solid black;
  }
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />

<div class="container">
  <div class="row">
    <div class="col-lg-6 col-md-12">A</div>
    <div class="col-lg-6 col-md-4 col-md-push-8 col-lg-push-0">B</div>
    <div class="col-lg-6 col-md-4 col-md-pull-4 col-lg-pull-0">C</div>
    <div class="col-lg-6 col-md-4 col-md-pull-4 col-lg-pull-0">D</div>
  </div>
</div>

By adding the class col-md-12 to the column A, it will take up the whole row and column B will flow to the next row. However, it will appear on the left side. If you want it to appear on the right side, you have to specifiy the col-*-pull-* and col-*-push-* classes.

niyasc
  • 4,440
  • 1
  • 23
  • 50
Syjin
  • 2,740
  • 1
  • 27
  • 31
  • That's it. It worked. I didn't know I could use more than 12 cols in a row... Thank you very much! :) – borbs Apr 26 '16 at 14:53
1

It's pretty easy and can be accomplished by defining classes "col-md-n col-lg-n col-md-push-m col-lg-push-m" (where n= no. of cols you want to display on md or a lg screen, m is a col count for push,pull classes). Check this snippet. Switch to full page and zoom in out to see the changes.

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container-fluid">
    
  <div class="row">
    <div class="col-lg-6 col-md-12 text-center" style="border:1px dashed pink;">
      <h1>A</h1>
      Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.<br>
      Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
    </div>
    <div class="col-lg-6 col-md-4  col-md-push-8 col-lg-push-0 text-center" style="border:1px dashed pink;">
        <h1>B</h1>
        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.<br>
      Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
    </div>
      <div class="col-lg-6 col-md-4 col-md-pull-4 col-lg-pull-0 text-center" style="border:1px dashed pink;">
        <h1>C</h1>
       Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.<br>
      Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.  
    </div>
      <div class="col-lg-6 col-md-4 col-md-pull-4 col-lg-pull-0 text-center" style="border:1px dashed pink;">
        <h1>D</h1>
       Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.<br>
      Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.    
    </div>
  </div>
</div>
    
</body>
</html>
Arun Sharma
  • 1,331
  • 8
  • 11