CSS position
- type
- property
- applies to
- any element
- inherits
- no
- common values
- static (default), relative, absolute, fixed, sticky
Where it goes
Wherever a box needs to leave the normal flow: an overlay, a pinned header, a badge in a corner.
Example
.badge-wrap {
position: relative;
}
.badge {
position: absolute;
top: 0;
right: 0;
}Common mistakes
- Using position: absolute with no parent that has position: relative. The box is then placed against the whole page instead of the box you meant.
- Using position to build a layout like a row of cards. That is a flexbox or grid job. position is for overlaps and pinning.