CSS Positioning Overview
CSS Positioning allows you to control the placement of elements on a webpage. There are four main types of positioning in CSS:
- Static: Default positioning, where elements flow into the document naturally.
- Relative: Positions an element relative to its normal position.
- Absolute: Positions an element relative to the nearest positioned ancestor.
- Fixed: Positions an element relative to the viewport and remains fixed as you scroll.
CSS Positioning Examples
Relative Box
Relative Child
Absolute Box
Absolute Child
Fixed Box (stays at the top-right of the screen)