Skip to content
Guest
Learn CSS · Course Syllabus Show lessons
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.

ValueBehaviorBest Use Case
relativeStays in flow; creates an anchor for absolute childrenCard containers holding corner badges
absolutePositioned relative to the nearest positioned ancestorNotification dots, close buttons, tags
stickyScrolls normally until hitting an edge (top: 0), then sticksNavigation bars, table headers, TOC sidebars
fixedPinned to the viewport regardless of scrollFloating 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.

Search courses, lessons, and references

Type to search across all courses, lessons, and quick references.

Press Esc to close Powered by Pagefind