CSS Grid breaks on Safari when a grid that looks fine in Chrome suddenly overflows, stretches, wraps strangely, or creates horizontal scroll on iPhone, iPad, or Safari desktop.
Browser CSS Fix
CSS Grid Breaks on Safari? Fix the Real Browser Bug
When CSS Grid breaks on Safari but works in Chrome, the bug usually feels unfair. You build a clean grid, test it in Chrome, resize the viewport, and everything looks fine. Then the same layout opens on iPhone or Safari and one card stretches, columns overflow, the page gets sideways scroll, or the grid refuses to collapse cleanly. Most of the time, Safari is not simply “ignoring Grid.” It is exposing a hidden sizing problem: fragile 1fr tracks, grid children that refuse to shrink, media that is wider than the column, long content, or an auto-fit minimum that is too wide for real mobile screens.
- Safari Grid bug
- iPhone layout issue
- 1fr sizing trap
- Horizontal scroll risk
What the bug looks like
Safari shows columns overflowing, cards becoming wider than their row, gaps looking wrong, or the entire page gaining horizontal scroll even though Chrome looked normal.
Why it happens
Safari often reveals minimum-size and intrinsic-sizing problems that were already present in the grid. Chrome may make the same layout look more forgiving during development.
What usually fixes it
Replace fragile track sizing, let children shrink, constrain media, and keep long content from forcing the grid wider than its container.
Why Safari grid bugs are usually not random
A CSS Grid bug in Safari often looks like a browser mystery because the same CSS appears to work elsewhere. But browser differences usually expose a deeper layout truth: the grid is being asked to distribute space, while one child is quietly refusing to become smaller.
The most common trap is assuming that 1fr means “always split the available space equally.” In real layouts, the content inside the track still matters. If a grid child has a long URL, a wide image, a button with white-space:nowrap, a code block, or a nested flex row, the grid track may become wider than expected.
That is why this issue often connects with other FrontFixer fixes like CSS Grid breaking on mobile, horizontal scroll on mobile, and text overflowing outside the box.
Using plain 1fr when content can overflow
The classic Safari Grid issue starts with a layout that looks harmless. Two columns. A gap. Cards inside. Then one card contains a long string, a button, or a nested component, and Safari lets that content pressure the track wider than you expected.
Broken code
1fr trap.layout {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 24px;
}
.card {
padding: 24px;
}
Broken visual result
The second card refuses to shrink, so the grid becomes wider than the visible area.
Correct code
Safer tracks.layout {
display: grid;
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
gap: 24px;
}
.card {
min-width: 0;
}
Fixed visual result
minmax(0,1fr) and min-width:0 tell the grid that the column and child are allowed to shrink.
Forgetting min-width:0 on grid children
This is one of the most important CSS layout fixes because it is invisible until the layout becomes tight. Grid children can have an automatic minimum size. That means a child may protect its content instead of shrinking to fit the available column. Safari can make this feel more dramatic.
Broken code
Auto minimum.grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
}
.grid-card {
overflow-wrap: anywhere;
}
Why this still breaks
The text may be allowed to wrap, but the grid item itself can still resist shrinking because its minimum size is not reset. That pressure can create Safari overflow.
Correct code
Child can shrink.grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
}
.grid > * {
min-width: 0;
}
.grid-card {
overflow-wrap: anywhere;
}
Why this is safer
The grid track can shrink, the child can shrink, and the content can wrap. All three layers work together instead of fighting each other.
Using an auto-fit minimum that is too wide for real phones
A grid pattern can look modern and still break on smaller screens. The common pattern repeat(auto-fit,minmax(320px,1fr)) may fail when the viewport is narrow, the wrapper has padding, and the grid also has gaps. Safari on iPhone makes this painfully visible.
Broken code
Too rigid.cards {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
gap: 24px;
}
Broken mobile result
Correct code
Mobile-safe.cards {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
gap: 20px;
}
.cards > * {
min-width: 0;
}
Fixed mobile result
Images, embeds, or media are wider than the grid item
Large images, videos, iframes, SVGs, and embeds can silently force a grid item to become wider than expected. If the media is not constrained, Safari may let the media pressure the entire grid.
Broken code
Media overflow.card img {
width: auto;
}
Broken media result
Correct code
Media containedimg,
video,
iframe {
max-width: 100%;
}
img,
video {
height: auto;
display: block;
}
Fixed media result
Long content inside the grid has no local overflow rule
Code blocks, tables, long URLs, and unbroken strings are dangerous inside CSS Grid. The right fix is not always to make the whole page hide overflow. Often the content itself needs a local scroll area or wrapping rule.
Broken code
Global pressurepre {
white-space: pre;
}
.grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
}
Why this breaks
The code block keeps its full line width. If that width is larger than the grid column, it can force the column and page wider.
Correct code
Local scrollpre {
max-width: 100%;
overflow-x: auto;
}
.grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
}
.grid > * {
min-width: 0;
}
Why this is cleaner
The code block handles its own overflow locally, while the grid remains inside the page layout.
Fast practical rule
If CSS Grid breaks on Safari but works in Chrome, test minmax(0,1fr) and min-width:0 before rewriting the whole component. Then check media, long content, auto-fit minimums, and accidental overflow. Most Safari Grid bugs are really hidden sizing bugs.
Why minmax(0,1fr) is the strongest Safari Grid fix
minmax(0,1fr) tells the browser that the grid track is allowed to shrink down to zero before free space is distributed. That sounds technical, but the practical meaning is simple: the content does not get to secretly decide the minimum column width.
A plain 1fr track can still be influenced by the minimum size of the content inside it. When you use minmax(0,1fr), you make the grid track more honest about the available space.
Production-safe grid pattern
Copy pattern.grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 24px;
}
.grid > * {
min-width: 0;
}
.grid img,
.grid video,
.grid iframe {
max-width: 100%;
}
Debug checklist
- Test the page in Safari desktop and on a real iPhone if possible.
- Check whether the page becomes wider than the viewport.
- Replace fragile
1frcolumns withminmax(0,1fr). - Add
min-width:0to direct grid children. - Constrain images, videos, iframes, embeds, and SVGs with
max-width:100%. - Check for long URLs, code blocks, button labels, or unbroken text inside grid items.
- Use
overflow-wrap:anywherewhere unpredictable text can appear. - Review
auto-fitandauto-fillminimum values on small screens. - Use local
overflow-x:autofor tables and code blocks instead of hiding overflow on the entire page. - Inspect nested flex layouts inside grid items, because they may also need
min-width:0.
min-width:0 to grid children and replace plain 1fr with minmax(0,1fr).
overflow-x:hidden.
Final takeaway
CSS Grid breaks on Safari when the layout depends on flexible tracks but the content inside those tracks is not allowed to shrink safely. Safari may expose the issue more clearly than Chrome, especially on iPhone and iPad, but the fix is usually in the grid structure.
Start with minmax(0,1fr). Add min-width:0 to grid children. Constrain media. Give long content a wrapping or local overflow rule. Then retest in Safari. Once the grid, the child, and the content all have permission to fit inside the available width, Safari Grid bugs become much less mysterious.
Want more fixes like this?
Explore the full FrontFixer fixes library and keep debugging with practical guides built for real front-end layout problems.