CSS achtergrond steno
CSS-achtergrond - steno-eigenschap
Om de code in te korten, is het ook mogelijk om alle achtergrondeigenschappen in één eigenschap op te geven. Dit wordt een steno-eigenschap genoemd.
In plaats van te schrijven:
body {
background-color: #ffffff;
background-image:
url("img_tree.png");
background-repeat: no-repeat;
background-position: right top;
}
U kunt de steno-eigenschap gebruiken background
:
Voorbeeld
Gebruik de steno-eigenschap om de achtergrondeigenschappen in één declaratie in te stellen:
body {
background: #ffffff url("img_tree.png") no-repeat right top;
}
Bij gebruik van de steno-eigenschap is de volgorde van de eigenschapswaarden:
background-color
background-image
background-repeat
background-attachment
background-position
Het maakt niet uit of een van de eigenschapswaarden ontbreekt, als de andere maar in deze volgorde staan. Houd er rekening mee dat we de eigenschap background-attachment niet gebruiken in de bovenstaande voorbeelden, omdat deze geen waarde heeft.
Alle CSS-achtergrondeigenschappen
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) |