May 04, 2021 CSS3
3. CSS3 background-image property
4. CSS3 background-size property
7. CSS3's background-Origin property
9.. More than one background image for CSS3
CSS3 has updated several new background properties to provide greater background element control, allowing you to make more beautiful styles.
In this section, you'll learn about four background attributes:
You'll also learn how to use multiple background images.
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-image
(with multiple backgrounds) |
4.0 | 9.0 | 3.6 | 3.1 | 11.5 |
background-size |
4.0
1.0 -webkit- |
9.0 |
4.0
3.6 -moz- |
4.1
3.0 -webkit- |
10.5
10.0 -o- |
background-origin | 1.0 | 9.0 | 4.0 | 3.0 | 10.5 |
background-clip | 4.0 | 9.0 | 4.0 | 3.0 | 10.5 |
Background pictures can be added in CSS3 through the background-image property.
The different background images and images are separated by commas, and the first one appears at the top of all the pictures.
You can set several different properties for different pictures
Background-size specifies the size of the background image. Before CSS3, the background image size was determined by the actual size of the image.
CSS3 can specify the background picture, let's re-specify the size of the background picture in different environments. You can specify a pixel or percentage size.
The size you specify is the size as a percentage of the width and height of the parent element.
Reset the background image:
Stretch the background image to completely fill the content area:
The background-Origin property specifies the location area of the background image.
Background images can be placed in content-box, padding-box, and border-box areas.
Locate the background picture in content-box:
CSS3 allows you to add multiple background images to an element.
Set two background images in the body element:
The background-clip background clipping property in CSS3 is drawn from the specified location
Order | Describe | Css |
---|---|---|
background-clip | Specifies the drawing area of the background. | 3 |
background-origin | Specify the positioning area of the background picture. | 3 |
background-size | Specify the size of the background picture. | 3 |
In the new CSS3 background properties, you can not only specify the drawing area of the background, but also surprise the positioning area and size of the background picture!