Lesson 11 of 50 · css
Positioning
Duration: 11 mins
Four positioning schemes:
| Value | Behaviour |
|---|---|
static | Normal flow (default). |
relative | Offset from its static position; keeps space in flow. |
absolute | Removed from flow; positioned relative to the nearest positioned ancestor. |
fixed | Removed from flow; positioned relative to the viewport (stays on scroll). |
sticky | Behaves like relative until a scroll threshold, then becomes fixed. |
Example: Sticky header
header { position:sticky; top:0; background:#fff; z-index:10; }