I am looking to design a layout with the following components:
- Left Sidebar
- Main Content
- Right Sidebar
- Extra Content
My goal is to achieve the following:
- On larger screens: Ensure that the "Extra Content" aligns directly below the main content with the same width and no gap between them.
- On smaller screens: Stack all elements vertically with full width, placing the Right Sidebar between the Main Content and Extra Content.
This is my current approach:
.row {
background: #dfdfdf;
}
.col {
background: #f8f9fa;
border: solid 1px #6c757d;
padding: 10px;
}
.tall {
height: 100px;
}
.xtall {
height: 200px;
}
.container.my-size .row {
margin-top: 30px;
}
.container.my-size .row .col {
background: #cdceff;
}
#sidebar-right {
float: right;
}
#main {
background: #ffeecd;
}
#extra {
background: #ffeecd;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/ [email protected]/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
<div class="container my-grids">
<div class="row flex-column flex-sm-row">
<div id="sidebar-left" class="col col-sm-3 order-sm-1 align-self-baseline">
<div class="tall">Left Sidebar</div>
</div>
<div id="main" class="col col-sm-6 order-sm-2 align-self-baseline">
<div class="">Main Content</div>
</div>
<div id="sidebar-right" class="col col-sm-3 order-sm-3 align-self-baseline">
<div class="tall">Right Sidebar</div>
</div>
<div id="extra" class="col col-sm-6 order-sm-4 align-self-baseline">
<div class="">Extra Content</div>
</div>
</div>
</div>
<!-- Displaying screen size -->
<div class="container my-size">
<div class="row">
<div class="col col-md-12 d-xs-block d-sm-none">Screen is <b>xs</b></div>
<div class="col col-md-12 d-none d-sm-block d-md-none">Screen is <b>sm</b></div>
<div class="col col-md-12 d-none d-md-block d-lg-none">Screen is <b>md</b></div>
<div class="col col-md-12 d-none d-lg-block d-xl-none">Screen is <b>lg</b></div>
<div class="col col-md-12 d-none d-xl-block d-xxl-none">Screen is <b>xl</b></div>
<div class="col col-md-12 d-none d-xxl-block">Screen is <b>xxl</b></div>
</div>
</div>
View Example Fiddle of my progress so far
Current Layout behavior:
Image illustrating the behavior of taller sidebars compared to main content
Image showing behavior when main content is taller than sidebars
Image displaying small screen behavior (desired result)
Desired Layout outcome:
Image depicting desired layout on larger screens
Image representing desired layout on larger screens
Image showcasing desired layout on small screens
Currently using Bootstrap 3, but open to solutions in Bootstrap 4/5 if necessary.