本文摘自PHP中文网,作者醉折花枝作酒筹,侵删。
在css中,可以使用“background-size”设置banner图自适应,语法“background-size:cover”;其中cover是指把背景图像扩展至足够大,以使背景图像完全覆盖背景区域。

本教程操作环境:windows7系统、CSS3&&HTML5版、Dell G3电脑。
1 2 3 4 5 6 7 8 9 10 11 12 13 | .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;
}
}
|
1 2 | <p class="index-banner-top"></p>
|
电脑端显示:
阅读剩余部分
相关阅读 >>
css border-right属性怎么用
css 搜索框怎么变大
如何使用内嵌式引入css样式表
怎么查看网站的css
css清除浮动的方法有哪些
css哪个样式不推荐使用
css中resize属性有什么用
css 伪类有哪些
css怎么设置p标签不换行
css怎么设置鼠标光标形状
更多相关阅读请进入《css》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » css如何设置banner图自适应