Specify the size of the background image:

div
{
background:url(img_flwr.gif);
background-size:80px 60px;
background-repeat:no-repeat;
}

Try it out . . .
There are more examples at the bottom of this page.

Browser support

The numbers in the table support the first browser version number of the property.

The number immediately before -webkit-, -ms- or -moz- is the first browser version number that supports the prefix property.

Property
background-size 4.0
1.0 -webkit-
9.0 4.0
3.6 -moz-
4.1
3.0 -webkit-
10.5
10.0 -o-

Label definition and instructions for use

The background-size property specifies the size of the background picture.

Default: auto
Inherited: no
Version: CSS3
JavaScript syntax: object object.style.backgroundSize="60px 80px"


Grammar

background-size: length | percentage |cover|contain;

value describe
length Set background picture height and width.The first value sets the width, the height of the second value setting.If only one value is given, the second is set to "auto" "
percentage The percentage of the background positioning area will be calculated.The first value sets the width, the height of the second value setting.If only one value is given, the second is set to "auto" "
cover At this time, the aspect ratio of the image is maintained and the image is scaled into the minimum size of the full coverage background.
contain At this time, the aspect ratio of the image is maintained and the image is scaled into the maximum size of the suitable background positioning area.


CSS3 background-size property

Online instance

Stretch the background image
Stretch the background image to completely cover the content area.

The four background images are stretched horizontally
Stretch 4 landscape background pictures.


Related articles

CSS3 tutorial: CSS3 background