Home > Web Front-end > CSS Tutorial > How to set full screen background image with css

How to set full screen background image with css

藏色散人
Release: 2022-12-30 11:11:28
Original
12146 people have browsed it

How to set a full-screen background image in css: first create an HTML sample file; then add a background icon to the body in css; and finally set the full-screen background image by adding the background-size style.

How to set full screen background image with css

The operating environment of this tutorial: windows7 system, HTML5&&CSS3 version, Dell G3 computer.

Recommendation: css video tutorial

We don’t enter anything in the html, it’s directly a body, plus styles.

How to set full screen background image with css

#Add a background icon to the body in css.

How to set full screen background image with css

#Run the page. When the picture is not very large, the background of the page only takes up part of it.

How to set full screen background image with css

#To cover the entire page, we can simply use the repeat attribute, which is barely possible.

How to set full screen background image with css

But this kind of paving is to reuse multiple identical pictures. This is only true when your background picture is a solid color or similar. acceptable.

How to set full screen background image with css

Another more perfect way is to add the background-size style and set it to 100%, which means that the background image will fill up.

How to set full screen background image with css

From the effect point of view, although the picture is stretched, overall it is acceptable.

How to set full screen background image with css

The above is the detailed content of How to set full screen background image with css. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
css
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template