Skip to content

Fix grid layout overflow on small screens and long uploader names - #13

Merged
DomDom3333 merged 2 commits into
mainfrom
claude/mobile-image-width-overflow-wnkay7
Aug 29, 2026
Merged

DomDom3333 merged 2 commits into
mainfrom
claude/mobile-image-width-overflow-wnkay7

Conversation

@DomDom3333

Copy link
Copy Markdown
Owner

Summary

Fixed CSS grid layout issues that caused the gallery to overflow the viewport width on small screens and when tile captions contain long uploader names.

Key Changes

  • Added min-width: 0 to .tile class to allow grid items to shrink below their content's minimum width, enabling proper text ellipsis on long uploader names
  • Updated small phone media query (max-width: 380px) to use repeat(2, minmax(0, 1fr)) instead of 1fr 1fr, preventing the grid from expanding beyond the screen width
  • Improved comments to explain the CSS grid behavior and rationale for these fixes

Implementation Details

The changes address a CSS Grid quirk where grid items have an automatic minimum size equal to their content's minimum width. This caused:

  1. Long uploader names in tile captions to prevent text wrapping/ellipsis
  2. The fixed two-column layout on small phones to overflow the viewport

By explicitly setting min-width: 0 on tiles and using minmax(0, 1fr) in the grid template, grid items can now shrink below their content size, allowing proper text truncation and preventing layout overflow.

https://claude.ai/code/session_011L4hw8a5wdb8Z3EYzY2jcn

On a 360px-wide phone the gallery falls to the two-column rule, which asked
for `1fr 1fr`. A bare `1fr` track has an automatic minimum of the item's own
content width, and a tile's caption holds the uploader name with
`white-space: nowrap` — so a long name sized the column instead of being
ellipsised, and the grid, the photos and the page with them ran off the side
of the screen. A 393px iPhone never hit this: above 380px the grid uses
`auto-fill, minmax(140px, 1fr)`, whose minimum is a fixed 140px.

Ask for `minmax(0, 1fr)` so the tracks may shrink to the space available, and
give the tile `min-width: 0` so a caption can never set the column's floor
again wherever the grid is used. Either alone fixes it; together the tile
carries its own guarantee.

Checked in headless Chromium at 360/384/393/412px against a replica of the
gallery: 782px of document on a 360px screen before, 360px after, with the
long name now clipped to an ellipsis.
@DomDom3333 DomDom3333 added bug Something isn't working run-tests and removed run-tests labels Aug 29, 2026
Removed unnecessary comments in the CSS file to improve readability.
@DomDom3333
DomDom3333 merged commit 8a29ba1 into main Aug 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working run-tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants