Responsive Sticky Rails
Part of the Responsive UI Patterns section of Coddy's Tailwind CSS journey. Lesson 44 of 55.
A sticky navigation rail can keep article sections within reach on a wide page. It stays in normal flow and sticks after reaching its top inset. In a narrow stacked layout, a static base often preserves a simpler reading sequence.
<nav aria-label="Guide sections" class="static md:sticky md:top-8 self-start"><a href="#overview">Overview</a></nav>The example activates sticky positioning at the medium breakpoint and reserves 32px from the top. self-start prevents the grid item from stretching to match a tall article, leaving it its own content height and useful movement space.
Account for other sticky surfaces. If a header already occupies the top of the page, the rail’s inset should include that height and any intended gap. Preserve semantic navigation rather than creating a visually similar noninteractive list.
Challenge
MediumKeep the article navigation statically positioned below 768px. From 768px upward, make it sticky 24px from the top and align it to the start of its grid area rather than stretching. Preserve the labeled navigation and article 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>
<div class="grid grid-cols-1 md:grid-cols-[160px_minmax(0,1fr)] gap-4"><nav id="sidebar" aria-label="Article sections" class="static"><a href="#section">Workshop guide</a></nav><article id="section" class="h-[1200px]">Long guide</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 Cards6Container Queries
Component Width QueriesBounded Component StatesNamed Query RegionsBounded Fluid ComponentsRecap: Container Queries9Layered Surfaces
Anchored Card BadgesLocal Layer BoundariesNonblocking DecorationResponsive Sticky RailsRecap: Layered Surfaces