Local Layer Boundaries
Part of the Responsive UI Patterns section of Coddy's Tailwind CSS journey. Lesson 42 of 55.
Overlapping surfaces need a deliberate paint order. isolate creates a stacking context on a component root, so its internal layers can be reasoned about together. Positioned descendants can then use z-0, z-10 or z-20 for their local order.
<article class="relative isolate"><div aria-hidden="true" class="absolute inset-0 z-0 bg-slate-100"></div><section class="relative z-10">Card content</section></article>The example places content above a decorative background inside an isolated card. The background fills the card with absolute inset-0, while the content stays positioned in normal flow. Mark purely decorative markup aria-hidden="true" so it does not add misleading accessible content.
Stacking numbers are not global escape codes. A descendant remains within its ancestor’s stacking context even when its own number is large. Preserve a sensible DOM order and use layering only for presentation.
Challenge
MediumGive the card its own isolated stacking context. Keep the decorative full-card layer at stacking level 0 and the positioned content at level 10. Preserve the decorative aria-hidden attribute and real reservation link.
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>
<article id="card" class="relative w-80 h-40 "><div id="decoration" aria-hidden="true" class="absolute inset-0 bg-slate-200 z-10"></div><section id="content" class="relative p-4 z-0"><h2>Open studio</h2><a href="#reserve">Reserve</a></section></article>
</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 Cards6Container Queries
Component Width QueriesBounded Component StatesNamed Query RegionsBounded Fluid ComponentsRecap: Container Queries9Layered Surfaces
Anchored Card BadgesLocal Layer BoundariesNonblocking DecorationResponsive Sticky RailsRecap: Layered Surfaces