我有一个网页,带有#wrap div居中页面的属性{margin:0 auto; }背景图片超过#wrap div
我的封面图片应该在宽度上(超过#wrap)和780px的高度。
由于#cover div位于居中的#wrap div内,因此图像无法从左侧的绝对点0开始。
我该如何解决这个问题?
我的HTML:
<div id="wrap">
<div id="cover"></div>
</div>
我的CSS:
#wrap {
width: 960px;
margin: 0 auto;
}
#cover {
background-image: url(bg.jpg);
background-attachment: fixed;
background-clip: border-box;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
height: 780px;
z-index: -10;
}
请提供必要的HTML代码来重现您的问题。 –
“我的封面图片应占用所有页面的宽度和780px的高度。” 请澄清:图像应该是'body'还是'#wrap'的宽度? – Moob