Skip to content

Keep the draw tiles whole under a host's CSS reset - #11

Merged
TokyoDanInJapan merged 1 commit into
mainfrom
fix/tiles-survive-css-resets
Aug 2, 2026
Merged

Keep the draw tiles whole under a host's CSS reset#11
TokyoDanInJapan merged 1 commit into
mainfrom
fix/tiles-survive-css-resets

Conversation

@TokyoDanInJapan

Copy link
Copy Markdown
Owner

The draw transition was broken on any site with a CSS reset — which is most of them.

What happened

Each tile holds the whole picture, sized to the grid (width: calc(var(--lb-cols) * 100%)) and shifted by left: calc(var(--c) * -100%) so the tile's own share shows through its overflow: hidden. That means an image several times wider than the box it sits in.

Nearly every reset forbids exactly that: Tailwind's preflight, normalize.css and the rest all carry img { max-width: 100% }. Clamped by one, the image is squeezed into a single tile, so:

  • the first column draws something, but object-fit: cover on a now tile-shaped box shows the middle of the photograph rather than that tile's slice;
  • every other column offsets the narrow image clean out of its own box and draws nothing;
  • the picture appears in one go when the seamless copy lands at the end.

Which reads as "the transition animates one column and then the image just appears". Found on a Tailwind site.

The fix

max-width: none and max-height: none on the tile's image, rather than hoping the host has not set a reset.

Test

tiles survive a host stylesheet that clamps images injects img { max-width: 100% }, opens a draw transition and asserts a tile's image still spans the whole grid rather than one tile. On the old CSS it measures 164px against an expected 820px — one fifth, the default five-column grid — so it is genuinely guarding the thing. 52 unit and 10 browser tests pass.

Each tile holds the whole picture, sized to the grid and shifted so that
the tile's own share of it shows through. That means an image several
times wider than the box it sits in - which nearly every reset forbids:
Tailwind's preflight, normalize.css and the rest all ship
`img { max-width: 100% }`.

Clamped by one of those, the image is squeezed into a single tile. The
first column still draws something, wrongly scaled; every tile past it
offsets that narrow image clean out of its own box and draws nothing at
all. The picture then appears in one go when the seamless copy lands,
which reads as the transition animating a single column and then giving
up.

`max-width: none` and `max-height: none` on the tile's image, rather
than hoping the host has not set a reset.
@TokyoDanInJapan
TokyoDanInJapan merged commit 292adc3 into main Aug 2, 2026
1 check passed
@TokyoDanInJapan
TokyoDanInJapan deleted the fix/tiles-survive-css-resets branch August 2, 2026 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant