Style bottom Property
Example
Set the bottom position of a <button> element:
document.getElementById("myBtn").style.bottom = "100px";
Try it Yourself »
Description
The bottom property sets or returns the bottom position of a positioned element.
This property specifies the bottom position of the element including padding, scrollbar, border and margin.
Tip: A positioned element is an element with the position property set to: relative, absolute, or fixed.
Tip: To set or return the top position of a positioned element, use the top property.
Browser Support
Property | |||||
---|---|---|---|---|---|
bottom | Yes | Yes | Yes | Yes | Yes |
Syntax
Return the bottom property:
object.style.bottom
Set the bottom property:
object.style.bottom = "auto|length|%|initial|inherit"
Property Values
Value | Description |
---|---|
auto | Lets the browser set the bottom position. This is default |
length | Defines the bottom position in length units. Negative values are allowed |
% | Sets the bottom position in % of the height of the parent element |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
Technical Details
Default Value: | auto |
---|---|
Return Value: | A String, representing the bottom position of a positioned element |
CSS Version | CSS2 |
More Examples
Example
Set the bottom position of a <div> element:
document.getElementById("myDiv").style.bottom = "10px";
Try it Yourself »
Example
Using negative values - Set the bottom position of a <div> element:
document.getElementById("myDiv").style.bottom = "-100px";
Try it Yourself »
Example
Return the bottom position of a <div> element:
alert(document.getElementById("myDiv").style.bottom);
Try it Yourself »
Related Pages
CSS tutorial: CSS Positioning
CSS reference: bottom property
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.