Positioning

๐ŸŽจ CSS3+ ๐ŸŸข Chapter 20 of 49 ๐Ÿ“‚ Phase 07: Display & Positioning ๐Ÿ“… 2026 Edition
๐Ÿ“Œ Covered in this chapter: static ยท relative ยท absolute ยท fixed ยท sticky ยท top/right/bottom/left ยท Containing Block ยท z-index ยท Stacking Context ยท Sticky Sidebar ยท Fixed Header ยท Modal
Welcome to Chapter 20: Positioning โ€” part of the CSS Complete Roadmap. This lesson covers all subtopics with clear explanations, code examples, and best practices used in professional web development.
1Position Values
PositionBehavior
staticDefault โ€” normal document flow
relativeOwn position nundi offset โ€” space reserved
absoluteNearest positioned ancestor ki relative
fixedViewport ki relative โ€” scroll avvadu
stickyHybrid โ€” scroll until threshold, then fixed
2Sticky Sidebar & Fixed Header
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
}

.sidebar {
  position: sticky;
  top: 20px;
  align-self: start;
}
3Containing Block, z-index & Stacking Context

Containing block: Absolute positioned elements nearest position: relative/absolute/fixed/sticky ancestor ni reference ga use chestayi.

CSS โ€” Modal
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal {
  position: relative;
  z-index: 1001;
}

Stacking context: New context creates properties โ€” position + z-index, opacity < 1, transform, filter. z-index only same context lo compare avuthundi.

OC
Written by Our Compiler Technical Editorial Team
Reviewed for accuracy ยท CSS Complete Roadmap ยท Last updated August 2026