Why Is My Grid Column Overflowing?

Grid column overflowing problems usually happen when CSS Grid columns use 1fr without minmax(0,1fr), fixed widths, long text, images, percentage columns plus gap, or missing responsive grid rules.

CSS Grid Overflow Fix

Why is my grid column overflowing?

A grid column overflowing can make a card stick out of the layout, create mobile horizontal scroll, cut off content, or make the whole page wider than the screen. The confusing part is that 1fr sounds flexible, but grid items still have automatic minimum sizes. Long text, images, fixed columns, and gaps can force a grid column wider than you expected.

  • CSS Grid
  • minmax(0, 1fr)
  • Long text
  • Mobile overflow

What the bug looks like

One grid column pushes outside the container, the last card is cut off, or the page gets horizontal scroll.

Why it happens

Grid tracks and grid items have minimum sizing behavior that can be stronger than the flexible layout you expected.

What usually fixes it

Use minmax(0,1fr), min-width:0, responsive minmax() tracks, and safe image/text rules.

Error 1

1fr columns are being pushed by long content

A grid column can overflow even with 1fr because the grid item’s automatic minimum size may be based on its content. Long text can force the column wider unless the track and item are allowed to shrink.

Broken code

1fr can still overflow
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

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

Broken visual result

Column pushed wider
overflow
Dashboard grid

Long content makes the first column wider than expected.

VeryLongUnbreakableGridColumnTitle Stats
1fr does not automatically mean “ignore long content.”

Correct code

minmax + min-width
.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

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

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

Fixed visual result

Column can shrink
fits
Dashboard grid

The column is allowed to shrink and the content can wrap safely.

VeryLongUnbreakableGridColumnTitle Stats
minmax(0,1fr) tells the grid track it can shrink below the content’s automatic minimum.
Error 2

Fixed grid columns are too wide for mobile

Fixed grid columns can look clean on desktop and break immediately on smaller containers. If the container is narrower than the combined column widths and gaps, the grid will overflow.

Broken code

Fixed desktop columns
.grid {
  display: grid;
  grid-template-columns: 220px 220px;
  gap: 12px;
}

Broken visual result

Fixed columns overflow
fixed width
Product grid

The columns keep desktop widths inside a smaller container.

Product Details
Fixed column widths cannot adapt when the available space gets smaller.

Correct code

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

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

Fixed visual result

Columns adapt
responsive
Product grid

The grid can reduce columns or stack before overflowing.

Product Details
Use responsive minmax() tracks instead of fixed desktop columns.
Error 3

Percentage columns plus gap are wider than the container

Two columns at 50% already equal the full container width. If you add a gap between them, the grid becomes wider than the container unless the column math accounts for the gap.

Broken code

100% + gap
.grid {
  display: grid;
  grid-template-columns: 50% 50%;
  gap: 18px;
}

Broken visual result

Gap adds extra width
gap overflow
Two-column section

The columns already take 100%, then the gap makes the grid too wide.

Left Right
Gap is real layout space. It is added between the tracks.

Correct code

fr columns include gap better
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

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

Fixed visual result

Gap fits inside layout
fits
Two-column section

The columns share the remaining space after the gap is considered.

Left Right
Fractional tracks are usually safer than percentage tracks when using grid gaps.
Error 4

An image inside the grid column is wider than the column

Sometimes the grid column is not the original problem. A child image, card, table, code block, or button inside the column is wider than the column and forces the grid track to expand.

Broken code

Image forces width
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.card img {
  width: 260px;
}

Broken visual result

Child content breaks track
wide child
Image grid

The image is wider than the grid column can safely hold.

Text
A fixed-width child can make the entire grid column overflow.

Correct code

Media respects column
.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.card img {
  display: block;
  max-width: 100%;
  height: auto;
}

Fixed visual result

Child content fits
safe image
Image grid

The image is constrained by the column instead of expanding it.

Text
Constrain media and other child content so it cannot force the grid track wider.
Premium pattern

A production-minded CSS Grid column pattern

A reliable grid pattern gives columns a safe minimum, allows child content to shrink, wraps long text, constrains media, and uses responsive tracks instead of fixed desktop assumptions.

Premium code

Safe responsive grid
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: clamp(12px, 2vw, 24px);
}

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

.grid img,
.grid video {
  display: block;
  max-width: 100%;
  height: auto;
}

.grid h3,
.grid p,
.grid a {
  overflow-wrap: anywhere;
}

@media (max-width: 520px) {
  .grid {
    grid-template-columns: 1fr;
  }
}

Premium visual result

Responsive grid, no overflow
premium
Production grid

The tracks, content, media, and gap all respect the container.

Feature card LongResponsiveGridContent Image safe
Premium grid CSS does not hide overflow. It prevents the column from creating it.

Fast practical rule

If a grid column is overflowing, try grid-template-columns:minmax(0,1fr) and min-width:0 on the grid child before using overflow-x:hidden. Then check long text, images, fixed widths, and percentage columns plus gap.

Debug checklist

  • Inspect the grid columns and check whether 1fr tracks need minmax(0,1fr).
  • Add min-width:0 to grid children that contain long text or nested content.
  • Look for fixed column widths that are too large for mobile containers.
  • Avoid 50% 50% plus gap unless the gap is accounted for.
  • Check images, videos, tables, code blocks, and buttons inside the grid column.
  • Use max-width:100% on media inside grid items.
  • Use overflow-wrap:anywhere for long words, URLs, or unbreakable labels.
  • Use responsive grid tracks like auto-fit with minmax().
Best first move Replace 1fr with minmax(0,1fr) on the overflowing track.
Most common cause Long content or images force the column wider than the layout expects.
Most sneaky cause 50% 50% columns plus gap quietly become wider than 100%.
Better mindset Grid columns are flexible only when their minimum sizing rules allow them to be flexible.

Final takeaway

A grid column overflowing is usually caused by minimum sizing, not by CSS Grid being broken. The column is being forced wider by long content, fixed widths, percentage tracks plus gap, or media that does not respect the column.

Start with minmax(0,1fr) and min-width:0. Then make text, images, gaps, and responsive tracks safe. That fixes the real grid overflow instead of hiding it.

Want more fixes like this?

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

Fix CSS Grid Breaking on Mobile

CSS Grid usually breaks on mobile when the grid tracks, gaps, or child elements demand more width than the screen can provide. The fix is not always abandoning Grid. The real fix is making the grid tracks flexible, letting children shrink, and giving mobile a simpler layout when space gets tight.

CSS Grid Mobile Fix

Why Is My CSS Grid Breaking on Mobile?

CSS Grid can look perfect on desktop and then suddenly crush cards, create horizontal scroll, squeeze content, or refuse to stack on phones. Most of the time, Grid is not broken. The layout is simply asking small screens to carry desktop-sized columns, gaps, or children.

  • Grid overflow bugs
  • Mobile track sizing
  • minmax and min-width fixes

What the bug looks like

Cards become tiny, text spills out, the page scrolls sideways, or the grid looks cramped and unstable on mobile.

Why it happens

The track sizing is too ambitious for the available width, or one child inside the grid refuses to shrink.

What fixes it

Use safer track sizing, reduce columns on mobile, control gaps, and add min-width:0 where grid children need to shrink.

The simple rule behind CSS Grid mobile bugs

A grid breaks on mobile when the total width requested by columns, gaps, padding, and child content is larger than the space available.

This can happen with obvious code like grid-template-columns: repeat(3, 300px), but it can also happen with elegant-looking rules like repeat(auto-fit, minmax(320px, 1fr)).

The fastest fix is usually to reduce the grid’s minimum demands and make the children flexible enough to fit.

Error 1

The grid keeps desktop columns on mobile

A desktop grid can look great at full width, but if it keeps three columns on a phone, the cards become cramped or overflow. Mobile usually needs a simpler column structure.

Broken code

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

Broken visual result

Three columns are squeezed
CardToo narrow.
CardToo narrow.
CardToo narrow.

Correct code

Mobile stack
.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
}

@media (max-width: 768px) {
  .cards {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

Fixed visual result

Cards stack cleanly
Card oneFull mobile width.
Card twoFull mobile width.
Card threeFull mobile width.
Error 2

The minmax() minimum is too large

auto-fit and minmax() are powerful, but they can still create mobile overflow if the minimum value is too ambitious for the real container width.

Broken code

Minimum too wide
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
}

Broken visual result

320px track is too demanding
320px minimumToo wide once padding is included.

Correct code

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

Fixed visual result

Track can respect the container
Safe minimumThe track can fit the available width.
Error 3

The grid child refuses to shrink

Sometimes the columns are fine, but one child inside the grid refuses to shrink. This commonly happens with long text, nested flex items, code blocks, images, and buttons.

Broken code

Child is too wide
.cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
}

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

Broken visual result

Child forces the grid wider
VeryLongUnbrokenGridCardTitle Cannot shrink safely.

Correct code

Child can shrink
.card {
  min-width: 0;
}

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

Fixed visual result

Child stays inside the grid
VeryLongUnbrokenGridCardTitle The content can wrap and the card can shrink.
Error 4

Gap and padding push the grid over the limit

A grid may almost fit on mobile, but large gaps and container padding can reduce the usable width enough to create horizontal overflow.

Broken code

Spacing too large
.wrapper {
  padding: 32px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(2, 145px);
  gap: 28px;
}

Broken visual result

Spacing eats the mobile width
CardAlmost fits.
CardBut gap pushes it.

Correct code

Mobile spacing
.wrapper {
  padding: 16px;
}

.cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

Fixed visual result

Spacing fits the screen
Card oneClean spacing.
Card twoNo overflow.
Error 5

Images and media are wider than the grid item

Images, videos, iframes, and embeds can break a grid when they do not respect the width of their card. The track may be correct, but the media inside it can still overflow.

Broken code

Media overflow
.card img {
  width: 520px;
}

Broken visual result

Media is wider than the card
Fixed-width image area The image forces the card wider than the viewport.

Correct code

Fluid media
.card img,
.card video,
.card iframe {
  max-width: 100%;
  height: auto;
  display: block;
}

Fixed visual result

Media respects the card
Fluid media area The media can scale down inside the grid item.

Fast practical rule

If CSS Grid is breaking on mobile, reduce the grid’s minimum demands first. Fewer columns, smaller gaps, flexible children, and min-width:0 solve more mobile Grid bugs than complicated track math.

Recommended baseline

Mobile-safe grid

This baseline gives the grid flexible tracks, allows children to shrink, keeps media fluid, and creates a simple mobile fallback.

.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
}

.card {
  min-width: 0;
}

.card img,
.card video,
.card iframe {
  max-width: 100%;
  height: auto;
  display: block;
}

.card-title,
.card-url,
.card-label {
  overflow-wrap: anywhere;
}

@media (max-width: 768px) {
  .cards {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

Why this baseline helps

It removes rigid track pressure minmax(0, 1fr) gives grid columns permission to shrink.
It protects against stubborn children min-width:0 helps grid items stop forcing overflow.
It makes media responsive Images, videos, and embeds stay inside their cards.
It gives mobile a clean fallback One column is often the safest and most readable mobile layout.

Debug checklist

  • Inspect the grid at the exact width where it first breaks.
  • Check whether the grid keeps too many columns on small screens.
  • Look for fixed track sizes like 300px, 320px, or aggressive minmax() values.
  • Add min-width:0 to grid items that contain long text, nested flex rows, images, or code blocks.
  • Check whether gaps and parent padding are making the usable width too small.
  • Make images, videos, iframes, and embeds fluid with max-width:100%.
  • Use overflow-wrap:anywhere for long strings, URLs, labels, and titles.
  • Switch to one column on mobile before trying more complex responsive grid formulas.
Best first move Temporarily set the grid to one column on mobile. If the bug disappears, your issue is track pressure or child overflow.
Most common false fix Rewriting the whole grid when one child simply needs min-width:0 or safer wrapping.
Most overlooked cause Big gaps and parent padding can make an otherwise reasonable grid overflow on a small screen.
Better mindset Mobile grids should be readable first and clever second. Predictable beats fancy when space is tight.

When overflow is the real problem

Sometimes Grid looks broken because one child is wider than the viewport. The grid is only revealing an overflow problem that already exists inside the content.

If the page scrolls sideways, read Fix overflow causing horizontal scroll.

When responsive design is the wider problem

If more than one section breaks on mobile, the issue may not be only Grid. The page may need a stronger responsive foundation.

In that case, read Why is my responsive design not working?.

When flex items inside the grid are the problem

A grid card can contain a flex row that refuses to shrink. That nested flex behavior can make the grid look guilty even when the grid track is fine.

If a nested flex child is involved, read Fix flex item shrinking with fixed width.

When the HTML structure is fighting the layout

Extra wrappers, missing containers, or weak grouping can make a grid harder to control across screen sizes.

If CSS patches keep failing, read Fix HTML structure problems.

Final takeaway

CSS Grid breaking on mobile is usually not a sign that Grid is unreliable. It is a sign that the layout is demanding more width than the screen can give.

Relax the track sizing. Let children shrink. Reduce gaps when needed. Make media fluid. Give mobile a simpler fallback before adding more clever formulas.

Once the grid’s minimum demands are realistic, CSS Grid becomes predictable again.

Need more CSS fixes?

Browse the CSS cluster or jump back to the full FrontFixer library to keep debugging faster.