In order to achieve the desired outcome, it is essential to incorporate both the order classes and the offset classes.
Firstly, addressing the columns:
col-lg-3
- col-lg-6
- col-lg-3
in the provided code signifies that the sidebar columns occupy 3 units on larger screens, while the center column accounts for 6 units (totaling 12 units).
For smaller screens (smaller than lg
), the center column expands to 8 units (col-8
) and the right column to 4 units (
col-4</code), maintaining a total of 12 units even on smaller screens. </p>
<p>Consequently, the left column necessitates <code>col-4
and an 8-unit offset on smaller screens to align directly below the right column.
Therefore, a specific combination of order and offset classes is crucial for the left column:
order-last order-lg-first offset-8 offset-lg-0
order-last
denotes the default order for the left column, applicable to the smallest screens (Bootstrap 4 follows a "mobile-first" approach).
order-lg-first
signifies that the left column gains priority from large (lg) screens and onwards.
offset-8
establishes the default offset for the smallest screens.
offset-lg-0
confirms that there should be no offset from the large (lg) screen size onwards.
Presented below is the functional code snippet:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<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>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>
<div class="container mt-3">
<div class="row">
<div class="col-4 col-lg-3 order-last order-lg-first offset-8 offset-lg-0 bg-warning">
<h2>1</h2>
Left content <br>
Left content <br>
Left content <br>
</div>
<div class="col-8 col-lg-6 bg-primary">
<h2>2</h2>
Center <br>
Center <br>
Center <br>
</div>
<div class="col-4 col-lg-3 bg-secondary">
<h2>3</h2>
Right content <br>
Right content <br>
Right content <br>
</div>
</div>
</div>