Propiedad de margen izquierdo de CSS
Ejemplo
Establezca el margen izquierdo para un elemento <p> en 30 píxeles:
p.ex1 {
margin-left: 30px;
}
Más ejemplos de "Pruébelo usted mismo" a continuación.
Definición y uso
La margin-left
propiedad establece el margen izquierdo de un elemento.
Nota: Se permiten valores negativos.
Valor por defecto: | 0 |
---|---|
Heredado: | No |
Animable: | si, ver propiedades individuales . Leer sobre animable |
Versión: | CSS1 |
Sintaxis de JavaScript: | objeto .style.marginLeft="100px" |
Compatibilidad con navegador
Los números de la tabla especifican la primera versión del navegador que es totalmente compatible con la propiedad.
Property | |||||
---|---|---|---|---|---|
margin-left | 1.0 | 6.0 | 1.0 | 1.0 | 3.5 |
Sintaxis CSS
margin-left: length|auto|initial|inherit;
Valores de propiedad
Value | Description | Play it |
---|---|---|
length | Specifies a fixed left margin in px, pt, cm, etc. Default value is 0px. Negative values are allowed. Read about length units | |
% | Specifies a left margin in percent of the width of the containing element | |
auto | The browser calculates a left margin | |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
Más ejemplos
Ejemplo
Establezca el margen izquierdo para un elemento <p> al 10% del ancho del contenedor:
p.ex1 {
margin-left: 10%;
}
Ejemplo
Establezca el margen izquierdo para un elemento <p> en 2 em:
p.ex1 {
margin-left: 2em;
}
páginas relacionadas
Tutorial CSS: Margen CSS
Referencia HTML DOM: propiedad marginLeft