如何在div中重复背景图片然后页面长度?
DIV(长于页面长度)背景停止重复
我有一个带有背景图片的HTML网页(在div中),一个div从页面顶部延伸到底部,还有一个div用于内容...但是DIV(从顶部延伸到底部)背景停止重复再往下看! (只要向下滚动,就没有更多背景图像)请帮忙!
这里是CSS:
html {
height:100%;
}
body {
background-color:#7E6F7F;
height:100%;
}
#bg { /*This is the background image for the whole page*/
position:fixed;
top:0;
left:0;
width:100%;
height:100%;
}
#main { /*This is the problem div!!!*/
padding:0px;
width:85%;
height:100%;
background-color:#D2B9D3;
background: url(Images/Background_Content.jpg);
background-attachment:fixed;
background-position:0% 0%;
position:relative;
top:0;
left:0;
z-index:1;
margin:auto;
}
#content { /*This is the the div for the content*/
display:block;
width:85%;
background-color:#E9CFEC;
padding:0.9375em; /*0.9375em=15px*/
border:0.125em solid #867687; /*0.125em=2px*/
text-align:justify;
-webkit-border-radius:15px;
-moz-border-radius:15px;
border-radius:15px;
-moz-box-shadow: inset 0 0 5px 5px #BAA6BD;
-webkit-box-shadow: inset 0 0 5px 5px #BAA6BD;
box-shadow: inset 0 0 5px 5px #BAA6BD;
}
谢谢你的帮助 :)
您需要使用background-repeat并将其设置为repeat-x , repeat-y或repeat-both 。
更多详细信息可以在这里找到。
编辑
啊,我现在看到了。 加载时,浏览器的#main是100%。 你会注意到重复停止了你滚动。 一个简单的解决方案是将# bottom:0添加到#main样式。 这将使它延伸到最底部。 另外,删除height: 100% 。
上一篇: How repeat background image in div longer then page length?
