【发布时间】:2016-07-21 13:24:20
【问题描述】:
我正在尝试让这个 div 背景充当正常的 100% 图像并以相同的方式缩放。
我的 CSS:
.videobackground{
margin-top:-5px;
max-width:1140px;
height:348px !important;
background-image:url(imgs/rpp-behind-the-scenes-hero2bg.jpg);
background-position:center; /* IE fix */
-webkit-background-size: contain;
-moz-background-size: contain;
-o-background-size: contain;
background-size: contain;
}
我的 HTML:
<div class="videobackground"></div>
这是我在桌面上的问题,看起来非常好。
桌面图片:
但是一旦我开始缩放页面,就会发生这种情况。
手机图片:
任何建议都将不胜感激,我觉得我几乎已经尝试了一切。我使用 div 背景而不是图像的原因是,我在 div 的左侧覆盖了嵌入的 youtube。
非常感谢!
亚当。
【问题讨论】:
-
你可以发送你的代码或链接吗?这样我就可以通过 firebug 来处理它
-
试试这个:`background-repeat:no-repeat'
-
background-repeat:no-repeat 不起作用,它只会阻止它重复并在我缩小时在顶部和底部显示空白。
-
@Ganesh 给我几分钟时间上传到我的服务器,我会拍摄一个链接。
-
你试过
background-size:cover吗?
标签: html css mobile responsive