Home >Web Front-end >H5 Tutorial >How to make the background image stretch and fill in css to avoid repeated display_html5 tutorial skills
How to make the background image stretch and fill, this question sounds simple. But I'm sorry to tell you. It's not as simple as we think.
For example, set a background in a container (body, div, span). The length and width of this background cannot be modified before CSS2.1.
So the actual result can only be displayed repeatedly, so the attributes repeat, repeat-x, repeat-y, and no-repeat appear. It is used to control the display of background images. So there are two types of background images :
1. A whole large image, the size of which exactly matches the area size
2. A very small bar image, After repeating, a very regular large picture background is formed.
But after the emergence of CSS3, this situation has been improved. The background-size property can make our previous wishes come true.
And this property can be used on firefox, chrome, and ie9.
The specific usage method is as follows:
Background image size (numeric representation):