Rosa’s pool timetable is rebuilt, and you’ve finished Fluid and Intrinsic Layouts. You can now build layouts whose type and spacing scale smoothly, whose cards line up across a row with subgrid, and whose components adapt to the space they’re given with container queries and units.
Before and After
- Fluid type: At
4vw, Riverside Lido’s timetable heading was 12.8 pixels on a phone 320 pixels wide, smaller than the text below it. In a browser window 1280 pixels wide, 200% zoom couldn’t enlarge it: it stayed 51.2 pixels on screen. With arempart insideclamp(), it’s 40 pixels on that phone. In the 1280-pixel window, it’s 45 pixels, and 200% zoom draws it 1.85 times as big, at about 83 pixels on screen. - Subgrid: The Leisure Centre’s long name pushed its opening times down below the other cards’. Now each pool card is a subgrid that spans the pool list’s three rows, so the names, the opening times and the lane badges share lines across the row.
- Container queries and units: The session card took its layout from a media query, which sees only the window. That squeezed the sidebar’s title into a column 73 pixels wide. Now the main column’s sessions and the sidebar are containers. The card goes wide only where its slot has room and sizes its title with
cqi. In the sidebar, a style query turns it compact. - Viewport units: On the phone model, the header at
100vhwas 720 pixels tall, so its last 80 pixels sat under the toolbar. Atmin-height: 100svh, it’s 640 pixels, and it keeps that height as the toolbar hides.
Things to Remember
- Fluid sizes keep a
rempart: check them at 200% zoom. - A subgridded card spans the rows it shares.
- A container unit measures the nearest container that answers for its axis, or else the small viewport.
- Keep a default that works without style queries.
- Full-height header:
min-height: 100svh. Full-screen panel:100dvh.