🌐CSS Position
Also known as position Property, position: absolute, position: sticky, position: fixed
The CSS rule that sets where a box goes. It can stay in line, move, or stick in view.
Think of it like
It is like choosing where a sticker goes. In a row, on a corner, or stuck to the window.
Example
Lucy wants a Chat button that stays in the corner while people scroll. She gives it position: fixed with bottom and right of 16px.
Why it matters
Pop-ups, sticky menus and badges on pictures all use it. Most layout, though, is better done with flexbox or grid.
Definition
Example code
css
.chat { position: fixed; bottom: 16px; right: 16px; }
.menu { position: sticky; top: 0; }Common mistake
Key takeaways
- 1static by default. The box stays in the normal flow.
- 2Pinned to a parent. absolute needs a placed parent.
- 3Pinned to the window. fixed and sticky stay in view.