Positioning Elements
The position property decides how an element is placed. Once positioned, you can nudge it with top, right, bottom, and left.
- static: the normal default flow
- relative: offset from its normal spot
- absolute: placed relative to the nearest positioned ancestor
- fixed: pinned to the screen even when scrolling
.badge {
position: absolute;
top: 8px;
right: 8px;
}
An absolute element looks for the nearest ancestor with position relative, absolute, or fixed. If none is found, it uses the page.
Try it yourself
Loading editor…