Stile marginBottom Proprietà
Esempio
Imposta il margine inferiore di un elemento <div>:
document.getElementById("myDiv").style.marginBottom = "50px";
Definizione e utilizzo
La proprietà marginBottom imposta o restituisce il margine inferiore di un elemento.
Sia la proprietà margin che la proprietà padding inseriscono spazio attorno a un elemento. Tuttavia, la differenza è che il margine inserisce lo spazio attorno al bordo, mentre il riempimento inserisce lo spazio all'interno del bordo di un elemento.
Supporto browser
Property | |||||
---|---|---|---|---|---|
marginBottom | Yes | Yes | Yes | Yes | Yes |
Sintassi
Restituisce la proprietà marginBottom:
object.style.marginBottom
Imposta la proprietà marginBottom:
object.style.marginBottom = "%|length|auto|initial|inherit"
Valori di proprietà
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 |
Dettagli tecnici
Valore di default: | 0 |
---|---|
Valore di ritorno: | Una stringa, che rappresenta il margine inferiore di un elemento |
Versione CSS | CSS1 |
Altri esempi
Esempio
Riporta il margine inferiore di un elemento <div> su "normale":
document.getElementById("myDiv").style.marginBottom = "0px";
Esempio
Restituisce il margine inferiore di un elemento <div>:
alert(document.getElementById("myDiv").style.marginBottom);
Esempio
Differenza tra marginBottom e paddingBottom:
function changeMargin() {
document.getElementById("myDiv").style.marginBottom = "100px";
}
function changePadding() {
document.getElementById("myDiv2").style.paddingBottom = "100px";
}
Pagine correlate
Tutorial CSS: margine CSS
Riferimento CSS: proprietà margin-bottom
Riferimento HTML DOM: proprietà margin
❮ Oggetto stile