Home > Web Front-end > HTML Tutorial > How to set the size of html background image

How to set the size of html background image

coldplay.xixi
Release: 2023-01-03 09:30:19
Original
64107 people have browsed it

How to set the size of the html background image: First create a new HTML page and set the background image for the tag; then set the [background-size] attribute for the body tag; finally set the width and height on the div tag.

How to set the size of html background image

The operating environment of this tutorial: Windows 7 system, HBuilderX.3.0.5 version, DELL G3 computer.

How to set the size of html background image:

1. In fact, most HTML editor operations are the same. Today I will explain it with Hbuilder. First of all Create a new HTML page, named here "new_file.html".

How to set the size of html background image

2. Then set the background image for the label. Here I set the

label.

How to set the size of html background image

#3. Then create a new css file, as shown in the picture, I named it "1.css".

How to set the size of html background image

4. Set the background-size attribute for the body tag here. If your tag is a div, write div, and then you can set the width and height.

How to set the size of html background image

5. As shown in the picture, write this in new_file.html: <link href="css/1.%20css" type="text/css" rel="stylesheet">You can set the size of the background image.

How to set the size of html background image

#6. Finally, preview it in the browser. This is only part of the background.

How to set the size of html background image

Related learning recommendations: html video tutorial

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

Related labels:
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