Skip to content
Chapter 20Lesson 10

Quiz - Layout and sizing

Quiz progress

0 / 0

A card has class="w-64 p-4 border-2" and renders exactly 256px wide (w-64 = 16rem = 256px). A teammate adds p-8 to give it more breathing room. What happens to the card’s rendered outer width?

It stays 256px — the larger padding eats into the content box, because Preflight set box-sizing: border-box.

It grows to 256px plus the extra padding on each side, pushing the outer edge wider.

It stays 256px, but only if you also add box-sizing: border-box yourself in a global reset.

You have a vertical list of rows spaced with space-y-4, and the last <li> is toggled off with the hidden class (it stays in the DOM). A faint extra gap hangs below the visible rows. Why — and what’s the 2026 fix?

space-y-* puts a bottom margin on every child except the structural last one; the hidden row is still last in the DOM, so the visible last row keeps a between-rows margin. Switch the parent to flex flex-col gap-4.

space-y-* adds a trailing margin after the final item; remove it by adding last:mb-0 to every row.

hidden reserves the row’s vertical space; swap it for invisible so the row collapses.

A flex row holds an avatar, a flex-1 middle region showing a long file URL, and a button. Instead of the URL truncating, the whole row blows past its container and shoves the button off the edge. What’s going on?

Flex items default to min-width: auto, which forbids shrinking below the content’s min-content width; add min-w-0 to the flex-1 item so it can shrink and truncate.

flex-1 only grows, never shrinks; switch it to flex-auto so the middle region can give space back.

The button needs shrink-0; without it the row can’t compute its width and overflows.

You want a card grid that creates as many equal columns as fit, each at least 16rem wide, with no breakpoints. Which approach matches that intent?

grid-cols-[repeat(auto-fit,minmax(16rem,1fr))] — the grid measures its own width and picks the column count.

grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 — let the breakpoints decide the count.

flex flex-wrap gap-6 with min-w-[16rem] on each card.

A full-screen hero uses h-screen (100vh). On iPhone Safari, the call-to-action at the bottom is hidden behind the address bar. What’s the reflex fix and why?

Use h-dvh (or min-h-dvh): vh is measured against the largest viewport (address bar collapsed), so a 100vh box runs past what’s visible while the bar shows. dvh tracks the live viewport.

Use h-lvh: it’s the mobile-aware unit that always accounts for the address bar.

Add overflow-hidden to the hero so the part behind the address bar gets clipped.

Inside a <button>, a decorative trash icon sits next to a visible “Delete” label. You want a screen reader to announce only “Delete,” not the icon. Which is correct?

Put aria-hidden="true" on the icon — it stays visible on screen but is pruned from the accessibility tree.

Put aria-hidden="true" on the <button> — the label is redundant anyway.

Give the icon class="invisible" so it’s hidden from assistive tech.

You add an absolute “New” badge inside a product card with top-2 right-2, but it lands in the top-right corner of the whole page instead of the card. What’s the one-class fix?

Add relative to the card — an absolute element anchors to its nearest positioned ancestor, and with none, it falls back to the viewport.

Add relative to the badge so its offsets resolve against itself.

Change the badge to fixed top-2 right-2 so it pins to the card.

You want to clip a card’s overflow at its edge without turning the card into a scroll container (so it never accidentally becomes a sticky ancestor or swallows an overhanging badge). Which value fits?

overflow-clip — it clips visually but does not create a scroll container.

overflow-hidden — it clips and is the clean, side-effect-free way to chop overflow.

overflow-auto — it clips and only shows a scrollbar when needed.

A modal at z-50 contains a tooltip you’ve set to z-[9999], yet the tooltip renders behind a sibling panel at z-40. The modal wrapper has opacity-95. Which statements are true? (Select all that apply.)

opacity less than 1 created a stacking context on the wrapper, scoping the tooltip’s z-index inside it.

The wrapper competes in the parent context at roughly 0, so the sibling at z-40 paints over the whole wrapper — tooltip included.

Bumping the tooltip higher (z-[99999]) would finally lift it above the sibling.

Portaling the tooltip to <body> would let it compete in the root context and render on top.

Quiz complete

Score by topic