To arrange the order of columns, you can utilize Bootstrap's order classes such as order-*
and order-sm-*
.
For instance:
- Column 1 - does not require a specific class as it maintains its original position.
- Column 2 has classes
order-sm-2 order-3
, making it appear second on screens wider than 576px, and third on smaller screens.
- Column 3 is assigned
order-sm-3 order-2
, placing it as the third column on larger screens and second on smaller ones.
An example using the sm
breakpoint:
.row div {
border: 1px solid #ccc;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<div class="container">
<div class="row justify-content-center">
<div class="col-4 col-sm-4"> 1 </div>
<div class="col-sm-4 col-6 order-sm-2 order-3"> 2 </div>
<div class="col-4 col-sm-4 order-sm-3 order-2"> 3 </div>
</div>
</div>
Another example using a larger breakpoint: Here are the same classes applied with a different breakpoint for comparison within the snippet:
.row div {
border: 1px solid #ccc;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<div class="container">
<div class="row justify-content-center">
<div class="col-4 col-lg-4"> 1 </div>
<div class="col-lg-4 col-6 order-lg-2 order-3"> 2 </div>
<div class="col-4 col-sm-4 order-lg-3 order-2"> 3 </div>
</div>
</div>