Style marginBottom attribute
- Προηγούμενη Σελίδα margin
- Επόμενη Σελίδα marginLeft
- Επιστροφή στο Επόμενο Ψηφίο Όντα Style του HTML DOM
Definition and usage
marginBottom
property sets or returns the bottom outside margin of an element.
margin property and padding property They both insert space around the element. However, the difference is that margin inserts space around the border, while padding inserts space inside the element's border.
See also:
CSS Tutorial:CSS Εξωτερικό Μέγεθος
CSS Reference Manual:margin-bottom property
HTML DOM Reference Manual:margin property
Instance
Example 1
Set the bottom outside margin of the <div> element:
document.getElementById("myDiv").style.marginBottom = "50px";
Example 2
Change the bottom outside margin of the <div> element back to "normal":
document.getElementById("myDiv").style.marginBottom = "0px";
Example 3
Return the bottom outside margin of the <div> element:
alert(document.getElementById("myDiv").style.marginBottom);
Example 4
Difference between marginBottom and paddingBottom:
function changeMargin() { document.getElementById("myDiv").style.marginBottom = "100px"; } function changePadding() { document.getElementById("myDiv2").style.paddingBottom = "100px"; }
Syntax
Return marginBottom property:
object.style.marginBottom
Set marginBottom property:
object.style.marginBottom = "%|length|auto|initial|inherit"
Property value
Value | Description |
---|---|
% | Defines the bottom outside margin as a percentage of the parent element's width. |
length | Defines the bottom outside margin with a length unit. |
auto | browser settings for the bottom outside margin. |
initial | Sets this property to its default value. See initial. |
inherit | Inherits this property from its parent element. See inherit. |
Technical details
Default value: | 0 |
---|---|
Return value: | A string representing the bottom outside margin of an element. |
CSS version: | CSS1 |
Υποστήριξη Browser
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Υποστήριξη | Υποστήριξη | Υποστήριξη | Υποστήριξη | Υποστήριξη |
- Προηγούμενη Σελίδα margin
- Επόμενη Σελίδα marginLeft
- Επιστροφή στο Επόμενο Ψηφίο Όντα Style του HTML DOM