-
The
background-sizeCSS property sets the size of the element's background image -
The image can be
- left to its natural size
- stretched
- constrained to fit the available space
-
Spaces not covered by a background image are filled with the
background-colorproperty, and thebackground colorwill be visible behind background images that have transparency/translucency -
The
background-sizeproperty is specified in one of the following ways-
Using the keyword values
containorcover -
Using a
widthvalue only, in which case theheightdefaults toauto -
Using both a
widthand aheightvalue, in which case the first sets thewidthand the second sets theheight -
Each value
can be a
length, apercentage, orauto
-
Using the keyword values
- To specify the size of multiple background images, separate the value for each one with a comma