I have a blog page using bootstrap 4 which has left and right sidebars and the main content.
On Desktop, It works perfectly fine.
But On Mobile phone they stacked in this order:- left-sidebar>content>right-sidebar
.
What I want is that on mobile phone, they must come in this order:- content>left-sidebar>right-sidebar
I have made a demonstration for this
body {
padding: 40px;
}
.left-sidebar, .content, .right-sidebar {
min-height: 300px; margin-bottom: 40px;border: 1px solid #aaa;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.6.0/css/bootstrap.min.css" rel="stylesheet"/>
<main>
<div class="container text-center">
<div class="row">
<div class="col-md-2">
<div class="left-sidebar p-4">Left Sidebar</div>
</div>
<div class="col-md-7">
<div class="content p-4">Content</div>
</div>
<div class="col-md-3">
<div class="right-sidebar p-4">Right Sidebar</div>
</div>
</div>
</div>
</main>
2
Answers
You can use the CSS
order
property at the mobile break-point.I think you have use media query or Grid-layout in CSS.
The CSS Grid Layout Module offers a grid-based layout system, with rows and columns, making it easier to design web pages without having to use floats and positioning.