The background property
is shorthand for background-color
, background-image
, background-position
, background-size
, background-repeat
, background-origin
, background-clip
, and background-attachment
.
Any of the above values are allowed to be omitted.
div.ex {
background: #0000ff url('example-image.jpg') no-repeat fixed right center;
}
background-color
Sets the color of the background.
background-image
Sets an image or multiple images as the background of an element.
background-position
Specifies the position at which a background image starts.
background-size
Specifies the size of a background image.
background-repeat
Sets how and if a background image will repeat itself.
background-origin
Designates the origin position of a background image.
background-clip
Sets how far the background should extend within an element.
background-attachment
Ensures the background-image
will or will not scroll with the page.
initial
Sets the property to its default value.
inherit
Inherits this property’s value from its parent item.
User-submitted codepen.io examples of background
↴
Submit a codepen.io link that demonstrates background
: