Files
freeCodeCamp/guide/english/css/background-size/index.md
BladeQue12 a18309352c Correct sentence on line 22 (#23257)
Added the words "the" and "a," so that the sentence will read correctly.  The sentence now reads as "To set this property on multiple background images, separate the values by a comma:"
2018-11-17 00:55:42 -05:00

1.4 KiB

title
title
Background Size

Background Size

The background-size property specifies the size of the background images. You can set a length or a percentage, with the first value being the width and the second one being the height. You can also use one of the 5 keyword values:

/* Background size property values that can be used */
.auto {background-size: auto;}
.cover {background-size: cover;}
.contain {background-size: contain;}
.initial {background-size: initial;}
.inherit {background-size: inherit;}
 /* Percentage, pixel, and viewport units can also be used */
.pixel {background-size: 50px 50px;}
.percentage {background-size: 50% 50%;}
.view {background-size: 50vw 50vh;}

Note: If using pixel or percentage for length and you only specify one value, the second one will be set to auto by default.

To set this property on multiple background images, separate the values by a comma:

.multiple {
    background-image: url(1.png), url(2.png);
    background-size: 3px 3px, cover;
}

More Information:

Documentation: MDN

CSS-Tricks: background-size

Browser Support: caniuse