Taquigrafía de fondo CSS
Fondo CSS - Propiedad abreviada
Para acortar el código, también es posible especificar todas las propiedades de fondo en una sola propiedad. Esto se llama una propiedad abreviada.
En lugar de escribir:
body {
background-color: #ffffff;
background-image:
url("img_tree.png");
background-repeat: no-repeat;
background-position: right top;
}
Puedes usar la propiedad abreviada background
:
Ejemplo
Use la propiedad abreviada para establecer las propiedades de fondo en una declaración:
body {
background: #ffffff url("img_tree.png") no-repeat right top;
}
Cuando se usa la propiedad abreviada, el orden de los valores de propiedad es:
background-color
background-image
background-repeat
background-attachment
background-position
No importa si falta uno de los valores de propiedad, siempre que los demás estén en este orden. Tenga en cuenta que no usamos la propiedad background-attachment en los ejemplos anteriores, ya que no tiene un valor.
Todas las propiedades de fondo CSS
Property | Description |
---|---|
background | Sets all the background properties in one declaration |
background-attachment | Sets whether a background image is fixed or scrolls with the rest of the page |
background-clip | Specifies the painting area of the background |
background-color | Sets the background color of an element |
background-image | Sets the background image for an element |
background-origin | Specifies where the background image(s) is/are positioned |
background-position | Sets the starting position of a background image |
background-repeat | Sets how a background image will be repeated |
background-size | Specifies the size of the background image(s) |