CSS agtergrond Snelskrif
CSS agtergrond - Snelskrif eiendom
Om die kode te verkort, is dit ook moontlik om al die agtergrondeienskappe in een enkele eiendom te spesifiseer. Dit word 'n snelskrif-eienskap genoem.
In plaas daarvan om te skryf:
body {
background-color: #ffffff;
background-image:
url("img_tree.png");
background-repeat: no-repeat;
background-position: right top;
}
Jy kan die snelskrif-eienskap gebruik background
:
Voorbeeld
Gebruik die snelskrif-eienskap om die agtergrondeienskappe in een verklaring te stel:
body {
background: #ffffff url("img_tree.png") no-repeat right top;
}
Wanneer die snelskrif-eienskap gebruik word, is die volgorde van die eiendomswaardes:
background-color
background-image
background-repeat
background-attachment
background-position
Dit maak nie saak of een van die eiendomswaardes ontbreek nie, solank die ander in hierdie volgorde is. Let daarop dat ons nie die agtergrond-aanhegsel-eienskap in die voorbeelde hierbo gebruik nie, aangesien dit nie 'n waarde het nie.
Alle CSS-agtergrondeienskappe
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) |