Definition and Usage
The bottom CSS property participates in specifying the position of positioned elements.
For absolutely positioned elements, that is those with position: absolute or position: fixed, it specifies the distance between the bottom margin edge of the element and the bottom edge of its containing block.
For relatively positioned elements, that is those with position: relative, it specifies the distance the element is moved above its normal position.
However, the top property overrides the bottom property, so if top is not auto, the computed value of bottom is the negative of the computed value of top.
- Initialauto
- Applies topositioned elements
- Inheritedno
- Percentagesrefer to the height of the containing block
- Mediavisual
- Computed Valueif specified as a length, the corresponding absolute length; if specified as a percentage, the specified value; otherwise, auto
- Animatableyes, as a length, percentage or calc(); when both values are lengths, they are interpolated as lengths; when both values are percentages, they are interpolated as percentages; otherwise, both values are converted into a calc() function that is the sum of a length and a percentage (each possibly zero), and these calc() functions have each half interpolated as real numbers.
- Canonical orderthe unique non-ambiguous order defined by the formal grammar
Syntax
Formal syntax: <length> | <percentage> | auto
bottom: 3px /* <length> values */
bottom: 2.4em
bottom: 10% /* <percentages> of the height of the containing block */
bottom: auto
bottom: inherit
Values
- <length>
- Is a negative, null or positive <length> that represents:
- for absolutely positioned elements, the distance to the bottom edge of the containing block;
- for relatively positioned elements, the offset that the element is moved above its position in the normal flow if it wasn’t positioned.
- <percentage>
- Is a <percentage> of the containing block’s height, used as described in the beginning (Definition).
- auto
- Is a keyword that represents:
- for absolutely positioned elements, the position the element based on the top property and treat height: auto as a height based on the content.
- for relatively positioned elements, the offset the element from its original position based on the top property, or if top is also auto, do not offset it at all.
- inherit
- Is a keyword indicating that the value is the same than the computed value from its parent element (which may not be its containing block). This computed value is then handled like it was a <length>, <percentage> or the auto keyword.
Examples
5 | border: 1px solid #000; |
The following sample page contrasts position:absolute and position:fixed. When the regular text becomes taller than the viewable portion of the page (the browser window’s viewport), blocks positioned with position:absolute will scroll with the page, while blocks positioned with position:fixed will not.
04 | <title>Position at bottom, absolute or fixed</title> |
05 | <style type="text/css"> |
06 | p {font-size:30px; line-height:3em;} |
07 | div.pos {width:49%; text-align:center; border:2px solid #00f;} |
08 | div#abs {position:absolute; bottom:0; left:0;} |
09 | div#fix {position:fixed; bottom:0; right:0;} |
13 | <p>This<br>is<br>some<br>tall,<br>tall, |
14 | <br>tall,<br>tall,<br>tall<br>content.</p> |
15 | <div id="fix" class="pos"><p>Fixed</p></div> |
16 | <div id="abs" class="pos"><p>Absolute</p></div> |
Compatibility
Desktop browsers
| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
| Basic support | 1.0 | 1.0 (1.7 or earlier) | 5 | 6 | 1.0 (85) |
Mobile browsers
| Feature | Android | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
| Basic support | NA | 1.0 (1.9.2) | NA | NA | NA |