Estilo marginBottom Propiedad
Ejemplo
Establezca el margen inferior de un elemento <div>:
document.getElementById("myDiv").style.marginBottom = "50px";
Definición y uso
La propiedad marginBottom establece o devuelve el margen inferior de un elemento.
Tanto la propiedad de margen como la propiedad de relleno insertan espacio alrededor de un elemento. Sin embargo, la diferencia es que margin inserta el espacio alrededor del borde, mientras que padding inserta el espacio dentro del borde de un elemento.
Compatibilidad con navegador
Property | |||||
---|---|---|---|---|---|
marginBottom | Yes | Yes | Yes | Yes | Yes |
Sintaxis
Devuelve la propiedad marginBottom:
object.style.marginBottom
Establezca la propiedad marginBottom:
object.style.marginBottom = "%|length|auto|initial|inherit"
Valores de propiedad
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 |
Detalles técnicos
Valor por defecto: | 0 |
---|---|
Valor de retorno: | Una cadena, que representa el margen inferior de un elemento. |
Versión CSS | CSS1 |
Más ejemplos
Ejemplo
Cambie el margen inferior de un elemento <div> a "normal":
document.getElementById("myDiv").style.marginBottom = "0px";
Ejemplo
Devuelve el margen inferior de un elemento <div>:
alert(document.getElementById("myDiv").style.marginBottom);
Ejemplo
Diferencia entre marginBottom y paddingBottom:
function changeMargin() {
document.getElementById("myDiv").style.marginBottom = "100px";
}
function changePadding() {
document.getElementById("myDiv2").style.paddingBottom = "100px";
}
páginas relacionadas
Tutorial CSS: Margen CSS
Referencia de CSS: propiedad de margen inferior
Referencia HTML DOM: propiedad de margen
❮ Objeto de estilo