Skip to content
Justice Tech School

Static, Relative, Absolute and Fixed

static is normal flow. relative offsets from its own place. absolute positions to the nearest positioned ancestor. fixed stays on screen. sticky switches between relative and fixed.

Example
<style>
.p { position: relative; height: 70px; background: #1e293b } .a { position: absolute; right: 8px; top: 8px; background: #f59e0b; color: #000; padding: 4px }
</style>
<div class="p">Relative parent<span class="a">absolute</span></div>

Exercise

Anchor for absolute children.

position: ;

Quiz Test

What does absolute position relative to?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.