Sphere
Log in Join
☆ 10

CSS grid column refuses to shrink below its content

Three-column layout with grid-template-columns: 1fr 1fr 1fr. One card contains a long unbroken URL and the whole grid blows out past the viewport. Why does 1fr not shrink?

⚑ Report

3 replies

☆ 0
R raven42 ·2026-10-24#1

1fr is minmax(auto, 1fr), and auto means min-content. The URL sets a large min-content width. Use minmax(0, 1fr) for columns that should be allowed to shrink.

⚑ Report
☆ 0
G glitch99 ·2026-10-24#2

Changed to minmax(0,1fr) and the grid fits, but the URL now overflows its card.

⚑ Report
☆ 0
A Anna ·2026-10-24#3

Add overflow-wrap: anywhere or overflow: hidden with text-overflow: ellipsis on the link. The grid fix and the text fix solve different parts.

⚑ Report
Log in to reply.