Shared Card Rows
Part of the Responsive UI Patterns section of Coddy's Tailwind CSS journey. Lesson 14 of 55.
Bottom-aligned actions solve one alignment problem, but sometimes headings, descriptions and actions must all line up across cards. CSS subgrid lets a nested grid use tracks defined by its parent while preserving each semantic article wrapper.
<div class="grid grid-cols-2 grid-rows-[48px_96px] gap-3"><article class="grid row-span-2 grid-rows-subgrid"><h2>Talk</h2><p>Details</p></article><article class="grid row-span-2 grid-rows-subgrid"><h2>Workshop</h2><p>Details</p></article></div>The example article spans two parent rows and uses grid-rows-subgrid. Its heading and paragraph then occupy those inherited rows. The card needs grid as well as the subgrid utility. For three or four regions, use row-span-3 or row-span-4 respectively.
Subgrid does not make rows equal. It shares the parent’s track sizes and gaps. This is useful when one card’s longer description should influence the description row used by neighboring cards.
Challenge
MediumUse the parent grid’s three supplied rows for both semantic cards. Each card must span all three rows and use a row subgrid, so headings share the 40px row, descriptions the 80px row and links the 32px row. Preserve the inherited 8px row gap.
Preserve the supplied content, semantic elements and IDs. Edit the requested utility classes. Press Run preview after edits, then Check/Run code to grade the result. Supplied JavaScript is read-only.
Try it yourself
<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Interface workshop</title><link rel="stylesheet" href="./styles.css"></head><body>
<div id="cards" class="grid grid-cols-2 grid-rows-[40px_80px_32px] gap-x-4 gap-y-2"><article id="a" class="grid grid-rows-3"><h2>Studio a</h2><p>Description</p><a href="#a">Details</a></article><article id="b" class="grid grid-rows-3"><h2>Studio b</h2><p>Description</p><a href="#b">Details</a></article></div>
</body></html>
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Responsive UI Patterns
1Page Shells
Growing Page ShellsFlexible Content RailsBounded Scroll RegionsFull-Bleed RegionsRecap: Page Shells4Form Layouts
Responsive Field GroupsFocused Field GroupsSelectable Form OptionsNative Validation CuesRecap: Form Layouts2Navigation Patterns
Wrapping NavigationCurrent Page CuesNative Menu DisclosuresKeyboard Skip LinksRecap: Navigation5Data Tables
Scrollable Data TablesPredictable Table ColumnsRow State PresentationSticky Table HeadersRecap: Data Tables8Interactive Panels
Expanded Control CuesChoice Card StatesFocus-Aware Help PanelsContent-Aware Empty StatesRecap: Interactive Panels11Project: Event Portal
Portal ShellSession Browser