Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To make the left column fill the space beside a fixed-width right column, define one flexible track and one fixed track. In CSS Grid, use grid-template-columns: minmax(0, 1fr) 20rem; the left side takes the remaining space and the right side is 20rem wide. The width and responsive breakpoint below are examples—adjust them for your content.

Build the layout with CSS Grid

Use Grid when you want to define two explicit columns. The 1fr track takes the available space left after the fixed track and the gap. Wrapping it in minmax(0, 1fr) lets the left track shrink below its automatic minimum when its content would otherwise make the layout too wide. See MDN’s Grid basics and grid-template-columns reference.

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 20rem;
  gap: 1rem;
}

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

Place the main content and sidebar inside the layout container:

<div class="layout">
  <main>Main content</main>
  <aside>Sidebar</aside>
</div>

In this example, the sidebar is 20rem wide, the gap is 1rem, and the columns stack below 48rem. These are design choices, not universal values; select a sidebar width and breakpoint that suit the actual content. MDN explains how fixed and fractional tracks can be combined in its common Grid layouts guide.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option

Why the left column should not be 100%

If “100%” means the left column should use all the space remaining beside the sidebar, use a flexible track such as 1fr. Setting the left column to 100% of the parent while also giving the right column a nonzero width leaves no room for the sidebar or gap, so the layout may overflow. The columns need to share the available width rather than each claim all of it.

Use Flexbox for a simple horizontal pair

Flexbox is also suitable when the main requirement is to distribute two items in one row. Let the main item grow and shrink, and give the sidebar a fixed width or basis:

.layout {
  display: flex;
  gap: 1rem;
}

main {
  flex: 1;
  min-width: 0;
}

aside {
  flex: 0 0 20rem;
}

@media (max-width: 48rem) {
  .layout {
    flex-direction: column;
  }

  aside {
    flex-basis: auto;
  }
}

Choose Grid when defining explicit columns is central to the component; choose Flexbox when the priority is distributing items along one dimension. MDN covers Flexbox space distribution and typical Flexbox use cases.

Fixed width is not fixed positioning

In a two-column width question, “fixed right column” usually means a sidebar whose width stays constant while the main column flexes. It remains in normal document flow. By contrast, position: fixed anchors an element relative to the viewport as the page scrolls. Use that only if the sidebar must stay in place during scrolling; it is a separate behavior, not what makes a column fixed-width.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Check the layout at narrow widths and with real content

  • Test the page at the point where the main content and sidebar no longer fit comfortably side by side, then adjust the stacking breakpoint to match.
  • Check long URLs, code, and other unbreakable content. A flexible track can still be affected by content sizing; minmax(0, 1fr) in Grid or min-width: 0 on a Flexbox item can help it shrink.
  • Test at increased browser zoom and with realistic sidebar content, not just short placeholder text.

Responsive layouts commonly change column definitions with media queries, but there is no universal breakpoint for this arrangement. Choose one based on when your own content needs more room; MDN demonstrates responsive Grid changes in its responsive design guide.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.