网页中顶部banner图自适应css

时间:2022-04-22 16:10:34
//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;
}
}
//test.html
<div class="index-banner-top"></div>

电脑端显示:

网页中顶部banner图自适应css

手机端显示:

网页中顶部banner图自适应css