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.

Why Does CSS Grid Need min-width:0?

CSS Grid min-width 0 fixes overflow when a grid item or grid track refuses to shrink because long text, media, URLs, cards, or content-based minimum sizes force the grid wider than its container.

CSS Grid Overflow Fix

Why does CSS Grid need min-width:0?

CSS Grid often needs min-width:0 because grid items can have a content-based minimum size. That means a grid column may look flexible on paper, but still refuse to shrink when the content inside it is long, unbroken, or naturally wide. The grid container may be responsive. The track may use 1fr. The page may have a safe wrapper. Still, one stubborn grid item can push the entire layout wider than the screen.

This is the grid version of a classic overflow trap. Developers see grid-template-columns: 1fr 1fr and expect both columns to share the available space. But 1fr does not always mean “ignore the content minimum.” If one grid item contains a long title, URL, code line, image, or nested card, the column can preserve more width than the parent has available. Adding min-width:0 to the grid item or using minmax(0, 1fr) on the track tells the grid that shrinking is allowed.

  • CSS Grid
  • min-width:0
  • Grid overflow
  • 1fr tracks

Test the grid item, not only the grid container

When a grid overflows, the container is not always the source. The grid item inside the track may be holding a content-based minimum width. Temporarily add min-width:0 to the grid children. If the scrollbar disappears, the grid needed shrink permission at the item level.

Related: Try this in the FrontFixer Live Inspector.

Open Live Inspector

What the bug looks like

A grid column becomes wider than the container even though the layout uses 1fr.

Why it happens

A grid item has a content-based minimum size that prevents the track from shrinking.

What usually fixes it

Use min-width:0 on grid items and minmax(0, 1fr) for shrinkable tracks.

Why 1fr can still overflow

1fr is often explained as “one fraction of the available space.” That is useful, but it can hide an important detail: the browser still has to respect the minimum size rules of the track and its content. If the content inside a grid item has a large minimum width, the track may not shrink down to the number you expect.

This is why two equal grid columns can suddenly become unequal or wider than the page. The track is not being stubborn for no reason. It is trying to avoid making the content smaller than its minimum. In many layouts, that default is helpful. In responsive cards, dashboards, media objects, and article layouts, it can create horizontal scroll.

The clean fix is to be explicit. If a column should be allowed to shrink below its content’s preferred width, use minmax(0, 1fr). If a child inside the grid should be allowed to fit the track, use min-width:0. Then decide whether the content should wrap, truncate, or scroll internally.

1fr is flexibleBut it can still preserve content-based minimum sizes.
minmax(0,1fr) is explicitIt tells the track the minimum can be zero.
min-width:0 helps childrenIt lets grid items fit the track instead of widening it.
Better mindsetFix the track and the item before hiding overflow.
Error 1

Two 1fr columns overflow because one item is too wide

The layout says two equal columns, but one grid item contains content that refuses to shrink. The browser tries to honor that content minimum, so the track expands and the whole grid becomes wider than the parent.

Broken code

1fr without zero minimum
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.grid > * {
  /* no min-width reset */
}

Broken visual result

Grid item pushes track
overflow
Two-column grid

The second item has long content and widens the row.

Short card VeryLongUnbrokenGridItemTitle
The column looks flexible, but the grid item keeps a content-based minimum width.

Correct code

Zero minimum track
.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

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

Fixed visual result

Tracks can shrink
fits
Two-column grid

The columns share available space and the child can truncate.

Short card VeryLongUnbrokenGridItemTitle
Use minmax(0,1fr) for tracks and min-width:0 for grid items.
Error 2

A URL or code line makes one grid column huge

Grid layouts often hold article cards, file rows, dashboards, and settings panels. A single long URL or code path can make one column wider than intended if the item is not allowed to shrink and truncate.

Broken code

Long text sets minimum
.file-grid {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 12px;
}

.file-url {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

Broken visual result

URL widens column
url
File grid

Ellipsis is written, but the grid item still holds its content width.

Path /frontfixer/live-inspector/components/grid-panel/index.css
The URL line cannot truncate until the grid item is allowed to shrink.

Correct code

Shrinkable URL column
.file-grid {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
  gap: 12px;
}

.file-url {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

Fixed visual result

URL truncates inside column
safe
File grid

The URL column can shrink, so the line truncates correctly.

Path /frontfixer/live-inspector/components/grid-panel/index.css
Put the zero minimum on the track and the grid item that owns the long text.
Error 3

A card grid uses large minimum tracks

Sometimes the issue is not the grid item but the track definition itself. If the track uses a large minimum like minmax(220px, 1fr), two columns plus gap may not fit a narrow container. The grid needs either fewer columns or a safer minimum.

Broken code

Minimum tracks too large
.cards {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr);
  gap: 12px;
}

Broken visual result

Tracks need too much space
track min
Card grid

The track minimums plus gap exceed the available width.

Card A Card B
Large minimum tracks can overflow before the cards even get a chance to adapt.

Correct code

Auto-fit safe columns
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
  gap: 12px;
}

.cards > * {
  min-width: 0;
}

Fixed visual result

Columns adapt
fits
Card grid

The grid creates only columns that can fit the available space.

Card A Card B
Use content-aware auto-fit patterns when fixed minimum columns are too fragile.
Error 4

A media grid has fixed media plus long copy

A thumbnail plus text layout can be built with Grid instead of Flexbox. The fixed media column is fine, but the copy column may still need minmax(0,1fr) and min-width:0 so long titles or descriptions do not push the grid wider.

Broken code

Copy column preserves text
.media-card {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 12px;
}

.media-copy {
  white-space: nowrap;
}

Broken visual result

Copy widens grid
media
Media grid

The fixed thumbnail plus long copy overflows the track.

Long media card title inside the grid refuses to shrink
The text column keeps more space than the grid container can provide.

Correct code

Copy column can shrink
.media-card {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr);
  gap: 12px;
}

.media-copy {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

Fixed visual result

Copy fits the track
safe
Media grid

The text column shrinks and truncates instead of widening the page.

Long media card title inside the grid refuses to shrink
Grid media objects need the same shrink permission as flex media objects.
Premium pattern

A production-minded CSS Grid min-width pattern

A reliable Grid system is explicit about which tracks may shrink, which children can fit the track, and how long content should behave. That usually means minmax(0,1fr) for flexible tracks, min-width:0 for grid children, and clear overflow rules for text, media, and nested components.

Premium code

Safe Grid shrink system
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(12px, 2vw, 24px);
  max-width: 100%;
}

.layout > * {
  min-width: 0;
}

.card-title,
.card-url {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
}

Premium visual result

Grid without hidden overflow
premium
Safe grid component

The tracks and children can shrink before the page width breaks.

minmax(0,1fr)
min-width:0
safe ellipsis
auto-fit cards
Premium Grid CSS does not assume 1fr fixes everything. It makes shrink behavior explicit.

Fast practical rule

If a CSS Grid layout overflows even with 1fr columns, add min-width:0 to the grid items and change flexible tracks to minmax(0,1fr). Then control long content with wrapping, ellipsis, internal scrolling, or a more responsive card pattern.

Debug checklist

  • Inspect the grid that becomes wider than its parent.
  • Check whether the grid uses 1fr where minmax(0,1fr) is safer.
  • Add min-width:0 to direct grid children and test whether overflow disappears.
  • Look for long URLs, code lines, product names, and no-wrap titles inside grid items.
  • Use ellipsis only after the grid item is allowed to shrink.
  • Replace large fixed track minimums with content-aware auto-fit patterns.
  • Check nested cards that bring their own min-width or fixed width.
  • Test the grid inside its smallest real parent, not only on a wide desktop canvas.
Best first moveAdd min-width:0 to the grid item and see if the scrollbar disappears.
Most common causeA long title, URL, or nested component creates a content-based minimum width.
Most sneaky causeThe grid uses 1fr, but the track still respects the content minimum.
Better mindsetMake shrink behavior explicit for both the track and the item.

When Grid should wrap instead of shrink

min-width:0 is not the only answer. Sometimes the better design is to reduce the number of columns, use auto-fit, or stack the content. If the grid contains important readable text, shrinking and truncating everything may make the layout technically fit but harder to use.

Use min-width:0 when the grid item should fit the track and the content can safely truncate, wrap, or scroll internally. Use a different grid template when the content truly needs more space. The strongest layouts combine both ideas: tracks that can shrink, items that can fit, and breakpoints that change only when the content has enough room.

Final takeaway

CSS Grid needs min-width:0 when a grid item keeps a content-based minimum size and prevents a flexible track from shrinking. A grid can use 1fr and still overflow if the item inside the track refuses to fit.

Use minmax(0,1fr) for tracks that should truly share available space, and use min-width:0 on grid children that contain long or stubborn content. Then choose the right behavior for that content: wrap it, truncate it, stack it, or let it scroll internally when necessary.

Want more fixes like this?

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