Menu
CoddyTech

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 icon

Challenge

Medium

Keep 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>
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Responsive UI Patterns