Content-sized Sidebar with Grid

suggest change

Use a max-content track when one column should take only the space its content needs and the other should fill the remainder:

.layout {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

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

max-content sizes the sidebar from its contents. minmax(0, 1fr) gives the content column the remaining space while allowing it to shrink. If the sidebar's intrinsic width might be excessive, constrain it:

.layout > aside {
  max-inline-size: min(20rem, 100%);
}

Feedback about page:

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



Table Of Contents