CSS Reference ยท Positioning and Stacking
The bottom property
Reference for the CSS bottom property: how it offsets positioned elements from the bottom edge, what percentages mean, and how it combines with top.
The bottom property sets the vertical offset of a positioned element from the bottom edge of its reference box. For an absolute element that is the padding edge of the nearest positioned ancestor, for fixed it is the viewport, and for sticky it is the bottom edge of the scrollport.
With position: static the property is ignored. A positive value moves the element's bottom edge up, away from the reference edge, which can feel backwards for relative elements: bottom: 10px shifts a relatively positioned box 10px upward.
.toast { position: fixed; bottom: 1rem; left: 1rem; }
Try it
Syntax
bottom: auto | <length> | <percentage> | <anchor()> | <anchor-size()>;
- Initial value:
auto - Applies to: positioned elements
- Inherited: no
- Percentages: refer to the height of the containing block
- Animatable: yes, as a length or percentage
- Computed value: for positioned elements, an absolute length or a percentage as specified;
autowhere it cannot be resolved; forstaticelements,auto
Values
| Value | Description |
|---|---|
auto |
No offset. The edge is determined by top and the element's height, or by normal flow. |
<length> |
A fixed distance from the bottom edge. Negative values push the element past the edge. |
<percentage> |
A percentage of the containing block's height. |
anchor(...) |
A position taken from an anchor element (see anchor positioning). |
Usage notes
- Bottom-anchored UI.
bottomis the natural choice for toasts, cookie banners and floating buttons that must stay at the bottom as the box height changes. - Containing block height matters. For
absoluteelements,bottomcounts from the bottom of the ancestor's padding box, so an ancestor that grows moves the element with it. topplusbottom. With both set andheight: auto, the element stretches between them (as in the third tag above). Ifheightis also set, the offsets are over-constrained andtopwins in horizontal left-to-right modes.- Mobile viewports. On phones,
position: fixed; bottom: 0can sit under the browser toolbar as it shows and hides. Test on real devices, or considerenv(safe-area-inset-bottom)for notches. - Animate with
transformrather thanbottomwhen you want smooth motion; changingbottomforces layout.
Browser support
Supported in every browser for many years.