Aligned Card Actions
Part of the Responsive UI Patterns section of Coddy's Tailwind CSS journey. Lesson 11 of 55.
Repeated cards often contain different amounts of text. A vertical flex card lets its content determine its own height while an automatic margin pushes the final action into the remaining space. This keeps the button or link aligned without removing any text from flow.
<article class="flex flex-col h-72"><h2>Watercolors</h2><p>Practice wet-on-wet painting.</p><a class="mt-auto" href="#watercolors">Explore</a></article>In this example, mt-auto belongs to the final link and flex flex-col belongs to its parent. The card must have spare height for the automatic margin to absorb. A grid row or a supplied fixed-height fixture can provide that height.
For several actions, wrap them in one final group. Give the group automatic top margin and its own horizontal flex layout. The group stays last in both the visual and reading order.
Challenge
MediumKeep both 256px cards as vertical flex containers. Place each supplied 40px action at the bottom using an automatic top margin, despite the different description heights. Preserve headings, descriptions and real links.
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 class="grid grid-cols-2 gap-4 h-64"><article id="a" class="block"><h2>Drawing</h2><p class="h-12">Sketching practice</p><a id="aAction" href="#a" class="h-10 block">View session</a></article><article id="b" class="block"><h2>Printmaking</h2><p class="h-24">Explore several printmaking techniques</p><a id="bAction" href="#b" class="h-10 block">View session</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 Browser3Content Cards
Aligned Card ActionsCard Media FramesResponsive Feature CardsShared Card RowsRecap: Content Cards