Atrybut background CSS
- previous page backface-visibility
- next page background-attachment
Definicja i zastosowanie
background
Krótkie atrybuty pozwalają ustawić wszystkie atrybuty tła w jednym deklaracji.
Możesz ustawić następujące atrybuty:
- background-color
- background-position
- background-size
- background-repeat
- background-origin
- background-clip
- background-attachment
- background-image
Jeśli nie ustawisz żadnej z wartości, nie będzie to problemem, na przykład background:#ff0000 url('smiley.gif'); jest dozwolone.
It is usually recommended to use this property instead of using individual properties separately, because this property is better supported in older browsers and requires fewer letters to be typed.
See also:
CSS tutorial:Tło CSS,CSS background (advanced)
HTML DOM reference manual:background property
Example
How to set all background properties in one declaration:
body { background: #00FF00 url(bgimage.gif) no-repeat fixed top; }
CSS syntax
background: bg-color bg-image position/bg-size bg-repeat bg-origin bg-clip bg-attachment initial|inherit;
Attribute value
Value | Description | CSS |
---|---|---|
background-color | Specifies the background color to be used. | 1 |
background-position | Specifies the position of the background image. | 1 |
background-size | Specifies the size of the background image. | 3 |
background-repeat | Specifies how the background image is repeated. | 1 |
background-origin | Specifies the positioning area of the background image. | 3 |
background-clip | Specifies the drawing area of the background. | 3 |
background-attachment | Specifies whether the background image is fixed or scrolls with the rest of the page. | 1 |
background-image | Specifies the background image to be used. | 1 |
inherit | Specifies that the background property settings should be inherited from the parent element. | 1 |
Technical details
Default value: | not specified |
---|---|
Inheritance: | no |
Version: | CSS1 + CSS3 |
JavaScript syntax: | object.style.background="white url(paper.gif) repeat-y" |
Browser support
The numbers in the table indicate the first browser version that fully supports this property.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
- previous page backface-visibility
- next page background-attachment