Styl margeBottom Eiendom
Voorbeeld
Stel die onderste kantlyn van 'n <div>-element:
document.getElementById("myDiv").style.marginBottom = "50px";
Definisie en gebruik
Die marginBottom-eienskap stel of gee die onderste marge van 'n element terug.
Beide die marge-eienskap en die padding-eienskap voeg spasie om 'n element in. Die verskil is egter dat marge die spasie om die grens invoeg, terwyl opvulling die spasie binne die grens van 'n element invoeg.
Blaaierondersteuning
Property | |||||
---|---|---|---|---|---|
marginBottom | Yes | Yes | Yes | Yes | Yes |
Sintaksis
Gee die marginBottom-eienskap terug:
object.style.marginBottom
Stel die marginBottom-eienskap:
object.style.marginBottom = "%|length|auto|initial|inherit"
Eiendomswaardes
Value | Description |
---|---|
% | Defines the bottom margin in % of the width of the parent element |
length | Defines the bottom margin in length units |
auto | The browser sets the bottom margin |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
Tegniese besonderhede
Standaard waarde: | 0 |
---|---|
Terugkeerwaarde: | 'n String, wat die onderste kantlyn van 'n element verteenwoordig |
CSS weergawe | CSS1 |
Meer voorbeelde
Voorbeeld
Verander die onderste kantlyn van 'n <div> element terug na "normaal":
document.getElementById("myDiv").style.marginBottom = "0px";
Voorbeeld
Gee die onderste kantlyn van 'n <div>-element terug:
alert(document.getElementById("myDiv").style.marginBottom);
Voorbeeld
Verskil tussen marginBottom en paddingBottom:
function changeMargin() {
document.getElementById("myDiv").style.marginBottom = "100px";
}
function changePadding() {
document.getElementById("myDiv2").style.paddingBottom = "100px";
}
Verwante bladsye
CSS handleiding: CSS Marge
CSS verwysing: marge-bottom eiendom
HTML DOM verwysing: marge eiendom
❮ Stylvoorwerp