Responsive Two-column Grid

suggest change

CSS Grid directly expresses a main-content and sidebar layout:

<div class="page-layout">
  <main>…</main>
  <aside>…</aside>
</div>
.page-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(14rem, 20rem);
  gap: 2rem;
}

@media (width < 48rem) {
  .page-layout {
    grid-template-columns: 1fr;
  }
}

minmax(0, 1fr) lets the main column shrink below the intrinsic width of long content instead of overflowing. Both columns stretch to the grid row's height by default. The range media-query syntax stacks the columns in narrower viewports.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents