1

I have a order of divs in bootstrap:

On normal computers i want:

first  second third

But on mobile i want:

third
second
first

I have checked the bootstrap grid system page and came up with this:

   <!doctype html>
    <html lang="en">
      <head>
        <!-- Required meta tags -->
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

        <!-- Bootstrap CSS -->
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

        <title>Hello, world!</title>
      </head>
      <body>

        <div class="container">
      <div class="row">
        <div class="col order-md-1 order-sm-3 order-xs-3">
          First,
        </div>
        <div class="col order-md-2 order-sm-2 order-xs-2">
          Second,
        </div>
        <div class="col order-md-3 order-sm-1 order-xs-1">
          Third,
        </div>
      </div>
    </div>

        <!-- Optional JavaScript -->
        <!-- jQuery first, then Popper.js, then Bootstrap JS -->
        <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
      </body>
    </html>

On mobile i keeps displaying:

first
second
third

Can anyone tell me what i am doing wrong?

JeffreyR
  • 591
  • 2
  • 9
  • 22

1 Answers1

1

This is all you need to re-order. The -xs- infix has been removed, and you just need the order for the smallest and medium.

https://codeply.com/go/mNZVT7Vpng

<div class="container">
    <div class="row">
        <div class="col order-md-1 order-3">
            First,
        </div>
        <div class="col order-2">
            Second,
        </div>
        <div class="col order-md-3 order-1">
            Third,
        </div>
    </div>
</div>

A-B-C to C-B-A


Also see: Bootstrap 4 grid - 3 stacked columns on left, 1 on right

Carol Skelly
  • 351,302
  • 90
  • 710
  • 624