Responsive Three-column Grid
suggest change<div class="three-column-layout">
<aside>Left sidebar</aside>
<main>Main content</main>
<aside>Right sidebar</aside>
</div>
.three-column-layout {
display: grid;
grid-template-columns:
minmax(12rem, 16rem)
minmax(0, 1fr)
minmax(12rem, 16rem);
gap: clamp(1rem, 3vw, 2rem);
}
@media (width < 64rem) {
.three-column-layout {
grid-template-columns: 1fr;
}
}
This layout needs no floats or clearing hack. Adjust the breakpoint according to when the actual content stops fitting, rather than targeting a particular device.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents