How to set the banner image adaptive in css

醉折花枝作酒筹
Release: 2023-01-05 16:08:30
Original
3225 people have browsed it

In css, you can use "background-size" to set the banner image adaptive, the syntax "background-size:cover"; where cover refers to expanding the background image to a large enough size so that the background image is completely covered background area.

How to set the banner image adaptive in css

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

//test.css .index-banner-top { width: 100%; background: url(../imgs/guanyu.png) no-repeat center center; height: 210px; background-size:cover } @media only screen and (max-width: 640px){ .index-banner-top { height: 100px; } }
Copy after login
rrree

Displayed on computer:

Displayed on mobile phone:

The above is the detailed content of How to set the banner image adaptive in css. 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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!