[英]How can I make a background with a left and right image border that repeats?
This is probably a very common question. 这可能是一个非常普遍的问题。 However I have tried to use every answer on the web, but for some strange reason there seems to be a clash in my stylesheet. 但是,我尝试使用网络上的每个答案,但是由于某些奇怪的原因,我的样式表似乎存在冲突。 I have a background with an image (cloth) pattern that repeats over the full content. 我的背景带有重复整个内容的图像(布料)图案。 Now I am trying to add one left and right border image (with threads, to make it look like a realistic cloth) to #container2, that repeats vertically down. 现在,我尝试向#container2添加一个左右边界图像(带有螺纹,使其看起来像一块现实的布料),并在垂直向下重复。 But every time I do this, the whole container moves down, and when I adjust the position, it disappears. 但是每次执行此操作时,整个容器都会向下移动,而当我调整位置时,它就会消失。
The code I have is as following: 我的代码如下:
<div id="container">
<div id="container2">
<div id="header">
....................content...............
</div>
</div>
</div>
CSS: CSS:
#container { background: #323232 url(images/container-bg.png) repeat; position: relative; }
#container2 { background: url(images/container-bg-right.png) repeat; min-height: 300px; padding: 0px 0 0px 3%; max-width: 1000px; margin: 0 5% 0 5%; }
#header { margin-bottom:50px; }
Thank you in advance. 先感谢您。
You can set multiple images for your backgrounds warning this isn't support by all browsers just yet 您可以为背景设置多张图片, 警告目前尚不支持所有浏览器
So your html could be: 因此,您的html可能是:
<div id="container">
<div id="inset-borders">
-- Content --
</div>
</div>
CSS: CSS:
#inset-borders {
background-image:url('left-border.png') left repeat-y, url('right-border.png') right repeat-y;
}
Wouldn't you want: 您是否想要:
<div id="container"> </div>
<div id="container2"> </div>
<divid="header"> </div>
Or do you want "container2" inside of "container" 还是要在“容器”中包含“ container2”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.