Home > Web Front-end > HTML Tutorial > How to adapt html background image to window size

How to adapt html background image to window size

醉折花枝作酒筹
Release: 2021-04-25 09:15:14
forward
8457 people have browsed it

This article will introduce to you how to adapt the html background image to the window size. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.

How to adapt html background image to window size

background-size:cover
Copy after login

will stretch the image to a large enough size, but some parts of the background image may not be fully displayed

#bgImg {
  height: 100%;
  width: 100%;
  background: url('../img/bg/snow.jpg') no-repeat;
  background-size: cover;
  position: absolute;
  overflow: hidden;}
Copy after login

The effect
Large window
How to adapt html background image to window size
Small window
How to adapt html background image to window size

background-size:contain
Copy after login

Stretch the picture to the maximum and display the picture completely
Large window
How to adapt html background image to window size
Small window
How to adapt html background image to window size

Recommended learning: html video tutorial

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

source:csdn.net
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