To create a layout resembling masonry-like columns, utilizing the standard Bootstrap grid system may not yield the desired outcome. Instead, integrating card columns or JavaScript masonry plugins would be necessary.
Implementing Card Columns Layout
<div class="container">
<div id="example" class="card-columns">
<div id="card1" class="card border-success">
<div class="card-body">
<p class="card-text">Card #1 - height: 20rem;</p>
</div>
</div>
<div id="card2" class="card border-success">
<div class="card-body">
<p class="card-text">Card #2 - height: 12rem;</p>
</div>
</div>
<div id="card3" class="card border-danger">
<div class="card-body">
<p class="card-text">Card #3 - height: 18rem;</p>
</div>
</div>
<div id="card4" class="card border-danger">
<div class="card-body">
<p class="card-text">Card #4 - height: 14rem;</p>
</div>
</div>
</div>
</div>
By applying minimal styling adjustments to configure 1 column for mobile view and 2 for other devices:
#example.card-columns {
column-count: 1;
}
@media(min-width: 576px) {
#example.card-columns {
column-count: 2;
}
}
You can achieve a layout that closely resembles your vision:
https://i.sstatic.net/4fyy8.png
View demo here: https://jsfiddle.net/davidliang2008/n3fhyp8c/60/
Issues on Mobile Display
However, an issue arises when viewing the layout on mobile devices due to the default CSS column order (top-bottom, left-right) which cannot be modified. To address this, duplicating content and toggling visibility based on screen breakpoints is required...
In case you intend to place both red boxes in the middle position (as per assumption):
<div id="card1" />
<div id="card2" class="card border-success d-none d-sm-block">
...
</div>
<div id="card3" />
<div id="card4" />
<div id="card2" class="card border-success d-block d-sm-none">
...
</div>
With this adjustment, you can achieve the desired display on mobile screens:
https://i.sstatic.net/WQQN2.png
View updated demo here: https://jsfiddle.net/davidliang2008/n3fhyp8c/63/