Why Does repeat(3, 1fr) Break on Mobile?

Grid repeat 3 columns breaks mobile layouts when a fixed three-column CSS Grid stays active on narrow screens instead of changing to two columns, one column, or an auto-fit pattern.

CSS Grid Mobile Fix

Why does repeat(3, 1fr) break on mobile?

repeat(3, 1fr) breaks on mobile when a grid keeps three columns even though the available width is too small. The browser does not automatically decide that three columns should become one column. It follows the CSS you wrote: three tracks, each sharing the available space. If the container becomes narrow, the columns either become tiny, overflow because of their content, or make the whole page feel squeezed.

The bug usually starts on desktop because grid-template-columns:repeat(3, 1fr) looks clean there. Three cards line up beautifully. The problem appears when that same rule reaches tablet, mobile, or a narrower content container. A grid that was elegant at 1200px can become unreadable at 390px.

  • CSS Grid
  • repeat(3, 1fr)
  • Mobile layout
  • Responsive columns

Test the grid at real mobile width

Resize the page slowly and watch the moment the three-column grid stops looking like a layout and starts looking like a trap. That breakpoint tells you where the grid needs a different column rule.

Related: Try this in the FrontFixer Live Inspector.

Open Live Inspector

What the bug looks like

Cards, products, posts, or feature boxes stay in three columns on a narrow screen.

Why it happens

repeat(3, 1fr) is a fixed column count. It does not automatically become responsive.

What usually fixes it

Change the column count at smaller widths or use auto-fit with a safe minimum.

Why three equal columns are not always responsive

The word 1fr makes a column feel flexible, but the number of columns is still fixed. repeat(3, 1fr) means “create three equal tracks.” It does not mean “create three tracks when there is room and fewer tracks when there is not.” That difference matters on mobile.

A three-column grid can fail in two different ways. Sometimes it technically fits, but each card becomes so narrow that the content looks broken. Other times, the content inside a column has a minimum width and pushes the grid wider than the viewport. Both problems come from using a desktop column count without a mobile strategy.

The clean fix is to define when the layout should change. That can be a media query, a container-aware rule, or a more fluid pattern using repeat(auto-fit, minmax(...)). The important thing is that the grid needs permission to stop being three columns.

1fr shares spaceIt does not choose the number of columns for you.
Three columns need roomCards, gaps, and padding all compete for mobile width.
Content can resist shrinkingLong labels and media may force tracks wider than expected.
Better mindsetDesktop column count and mobile column count should be separate decisions.
Error 1

The desktop three-column grid stays active on mobile

The most common mistake is using repeat(3, 1fr) for a card grid and never changing it. On mobile, the browser keeps three columns because that is the rule. The cards become too narrow or overflow depending on their content.

Broken code

Desktop rule everywhere
.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

Broken visual result

Three columns trapped
too tight
Feature grid

The desktop three-column structure stays active.

Card A Card B Card C
The grid is obeying the CSS: three columns, even when the screen is too narrow.

Correct code

Mobile fallback
.cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 700px) {
  .cards {
    grid-template-columns: repeat(3, 1fr);
  }
}

Fixed visual result

Mobile gets one column
safe
Feature grid

The mobile layout starts with one readable column.

Card A Card B Card C
Start mobile-first, then add three columns only when there is enough space.
Error 2

Gap and padding leave too little space for each column

Even when the grid does not technically overflow, the cards can become unusable. Three columns plus two gaps plus container padding can leave each card with a tiny width. The layout is not broken by syntax; it is broken by available space.

Broken code

Too many tracks
.products {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
  padding: 20px;
}

Broken visual result

Gap squeezes cards
squeezed
Product grid

The gap consumes width before the cards get space.

One Two Three
On mobile, fixed gaps and three columns can make every card feel crushed.

Correct code

Responsive gap and columns
.products {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(12px, 3vw, 22px);
  padding: clamp(12px, 3vw, 20px);
}

@media (min-width: 760px) {
  .products {
    grid-template-columns: repeat(3, 1fr);
  }
}

Fixed visual result

Space scales down
balanced
Product grid

The grid uses fewer columns and softer spacing on small screens.

One Two Three
Responsive columns and responsive spacing should usually work together.
Error 3

Long content inside a 1fr column forces overflow

Sometimes repeat(3, 1fr) fails because one column contains content that will not shrink. Long product names, URLs, labels, code, or buttons can create a minimum width that pushes the track wider than the container.

Broken code

Content controls track
.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.card-title {
  white-space: nowrap;
}

Broken visual result

Long title leaks
content
Article cards

A long title can make the track wider.

VeryLongUnbrokenCardTitle Card B Card C
The grid columns are equal, but the content inside one card refuses to shrink.

Correct code

Tracks and content can shrink
.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.card {
  min-width: 0;
}

.card-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

Fixed visual result

Content stays inside
controlled
Article cards

The track can shrink and the title is handled inside the card.

VeryLongUnbrokenCardTitle Card B Card C
Use minmax(0,1fr) and min-width:0 when content needs to stay inside grid tracks.
Error 4

The grid is inside a narrower parent

A grid can break even before the viewport gets small if it lives inside a narrow parent. A sidebar, tab panel, modal, article column, or card body may be much narrower than the full page. A three-column grid inside that parent needs to respond to the parent’s available width.

Broken code

Viewport thinking only
.sidebar-widget .links {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

Broken visual result

Parent too narrow
nested
Sidebar widget

The nested grid has less room than the page.

Side A B C
The grid should respond to its actual container, not only the whole viewport.

Correct code

Container-safe pattern
.sidebar-widget .links {
  display: grid;
  grid-template-columns:
    repeat(auto-fit, minmax(min(100%, 120px), 1fr));
  gap: 8px;
}

.sidebar-widget .link {
  min-width: 0;
}

Fixed visual result

Parent-aware fit
safe
Sidebar widget

The nested grid chooses fewer columns inside the parent.

Side A B C
For nested grids, use patterns that respect the component’s actual width.
Premium pattern

A production-minded responsive grid pattern

A premium grid does not force three columns everywhere. It starts with readable mobile behavior, then expands as space allows. The safest pattern combines auto-fit, minmax(), responsive gaps, and min-width:0 on the card content.

Premium code

Fluid card grid
.card-grid {
  display: grid;
  grid-template-columns:
    repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: clamp(14px, 2vw, 24px);
}

.card-grid > * {
  min-width: 0;
}

.card-title {
  overflow-wrap: anywhere;
}

.card-media {
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

Premium visual result

Grid expands naturally
premium
Responsive card grid

The grid adds columns only when each card has enough room.

Mobile
1 readable column
Desktop
Card Card Auto-fit fills space
Premium CSS Grid lets the layout breathe. It does not worship three columns when the container is too small.

Fast practical rule

Use repeat(3, 1fr) only when you know the container has room for three readable columns. For mobile, start with one column or use auto-fit with minmax(). Three equal columns are a desktop pattern, not a universal responsive rule.

Debug checklist

  • Search for grid-template-columns:repeat(3, 1fr).
  • Check whether the same rule is active on mobile.
  • Resize slowly and find where three columns stop being readable.
  • Account for gap, padding, and container width, not only viewport width.
  • Use a mobile-first one-column default when readability matters.
  • Use repeat(3, minmax(0, 1fr)) when long content causes track overflow.
  • Add min-width:0 to grid children that contain long content.
  • Use auto-fit with minmax(min(100%, ...), 1fr) for more flexible components.
Best first moveSwitch mobile to grid-template-columns:1fr and compare the result.
Most common causeThe desktop three-column rule is still active on a narrow screen.
Most sneaky causeThe grid lives inside a narrower parent and breaks before the viewport does.
Better mindsetResponsive grids should respond to available space, not just a desktop mockup.

When repeat(3, 1fr) is still okay

repeat(3, 1fr) is not wrong by itself. It is a clean desktop rule when the container is wide enough and the content inside each card is controlled. It becomes risky when it is treated as a complete responsive strategy.

A strong production layout may still use three columns at larger widths. The difference is that it also defines what happens before that point. Mobile might use one column. Tablet might use two. Desktop might use three. Or the grid might use auto-fit and let the component decide based on available space.

The authority move is not to avoid three columns forever. The authority move is to stop forcing three columns when the user’s screen, parent container, or content says the layout needs fewer.

Why this bug survives desktop review

A three-column grid can look perfect while you are building on a wide screen. That is why this bug often survives until the final mobile check. The layout is not visually broken at first; it is only waiting for the container to become narrow enough.

The safest habit is to inspect the grid at the component level. Check the width of the actual grid parent, not only the browser window. If the parent is a content column, modal, sidebar, tab panel, or card body, it may need fewer columns much earlier than the full page does.

Final takeaway

repeat(3, 1fr) breaks on mobile because it keeps a fixed three-column structure inside a space that may only support one or two readable columns. The 1fr unit shares space, but it does not choose a better column count.

Use three columns when the container has room. Use one column, two columns, or auto-fit when it does not. That turns CSS Grid from a desktop-only layout into a responsive system that respects the user’s screen and the component’s real width.

Want more fixes like this?

Browse more CSS Grid, overflow, responsive design, and mobile layout debugging guides in the FrontFixer library.