CSS Reference Property

bottom

The bottom property is an offset property that is used to specify the bottom offset of a positioned element with respect to its positioning context.

It is one of four available offset properties that also include right, top, and left.

Offset properties are used to specify the exact position of a positioned element and have no effect on non-positioned (static) elements. In order to use this property, the element should have a position value other than the default static.

The bottom property specifies how far an absolutely positioned element’s bottom margin edge is offset above (or below) the bottom edge of the element’s positioning context, which is usually its containing block. For relatively positioned elements, the offset is with respect to the bottom edge of the element itself (i.e., the element is given a position in the normal flow, then offset from that position according to the offset properties). For fixed and sticky elements the positioning context is the viewport.

You should read the position property entry for details on how to choose a position for an element to use the offset properties on it.

If an element has a specified height, then the bottom property will be overridden by the top property if the top property is set to any value other than auto. If the element does not have a specified height and the top property is set along with the bottom property, the element will stretch so that its top and bottom edges are positioned according to the top and bottom offsets.

Official Syntax

  • Syntax:

    bottom: <length> | <percentage> | auto
  • Initial: auto
  • Applies To: positioned elements
  • Animatable: yes, as a length, percentage or calc();

Values

<length>

The bottom offset is specified as a fixed length. See the <length> entry for a list of possible length values and units.

Negative values are allowed. A positive value will offset the element upwards from the bottom edge of its positioning context, while a negative value will offset it downwards with respect to the bottom edge of the context.

<percentage>

The bottom offset is specified as a percentage of its containing block’s height. See the <length> entry for a list of possible length values and units.

Negative values are allowed. A positive value will offset the element upwards from the bottom edge of its positioning context, while a negative value will offset it downwards with respect to the bottom edge of the context.

auto
When bottom is set to auto then:

  • If the element is relatively positioned, it will be positioned (vertically) according to the value of the top property, and if the top property is also set to auto, the element is not offset vertically at all. (It could still be offset horizontal using one of the horizontal offset properties left and right.)
  • If the element is absolutely positioned, it will be positioned (vertically) according to the value of the top property, and if its height is height: auto, it will get its height based on its content.

Notes

The bottom offset property also accepts a value of inherit, which allows the element to inherit its bottom offset from its parent. The element’s parent may not be its positioning context.

Examples

The following example offsets an absolutely positioned element by 30px above the bottom edge of its containing block (which in this case is its positioning context).

.container {
    position: relative; /* establishes a positioning context for its absolutely positioned descendants and for itself */
}

.absolutely-positioned {
    position: absolute;
    bottom: 30px;
}
                

Live Demo

Have a look at some examples in the following live demo:

View this demo on the Codrops Playground

Browser Support

The bottom property is supported in all major browsers: Chrome, Firefox, Safari, Opera, Internet Explorer, and on Android and iOS.

Further Reading

Written by . Last updated February 4, 2015 at 2:53 pm by Manoela Ilic.

Do you have a suggestion, question or want to contribute? Submit an issue.