Layout Systems · 8 min read · Beginner
Positioning, Sticky Headers & Layering
Master relative, absolute, and sticky positioning to pin navbars, overlay badges, and control stacking order cleanly.
What you'll learn
- Anchor an absolute badge inside a relative parent container
- Pin a header inside a scrollable region using position: sticky
- Avoid common pitfalls that break sticky positioning
CSS position lets you take elements out of normal document flow or keep them pinned while scrolling.
| Value | Behavior | Best Use Case |
|---|---|---|
relative | Stays in flow; creates an anchor for absolute children | Card containers holding corner badges |
absolute | Positioned relative to the nearest positioned ancestor | Notification dots, close buttons, tags |
sticky | Scrolls normally until hitting an edge (top: 0), then sticks | Navigation bars, table headers, TOC sidebars |
fixed | Pinned to the viewport regardless of scroll | Floating help buttons, persistent banners |
Try It Yourself
Scroll inside the preview box to see the sticky header pin to the top while the absolute badge stays anchored to its card:
Sticky Header & Absolute Badge
Live Result
Check Your Understanding
Score: 0 / 1
1. To anchor an absolute badge to the top-right corner of a card, what position should the card itself have?
Study Workspace
Finished this lesson?
Your progress is saved locally in your browser, no account needed.