简体   繁体   English

如何制作具有重复的左右图像边框的背景?

[英]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.

相关问题 我怎样才能使箭头边框右背景彩色 - how can I make the arrow border right background colorful 如何使底部边框从左侧增长并最小化到右侧? - How can I make the bottom border grow from the left side and minimize to the right side? 标题图像与背景重复:封面;。 我怎样才能解决这个问题? - Header image repeats with background: cover;. How can I fix this? 如何在 CSS 背景中实现具有 50% 宽度且具有底部和部分左边框的图像? - How can I achieve in CSS background with image that has 50% width and it has bottom and part of the left border? 如何删除背景图片中的边框? - How can I remove border in background image? 在其左右两侧留有多余空间的边框,如何解决? - Border with extra space on the left and right of it, how can I fix it? 我可以在背景图像的左右添加负边距吗? - Can I add negative margin left and right to an background image? 如何将速记 CSS 属性(border、border-left、border-right...)导出为 CSS 变量 - How can i export shorthand CSS properties (border, border-left, border-right...) as CSS variables 如何仅显示页面上背景图像的左右暂停? - How can i show only the right/left halt of a background image on my page? 如何将背景图像定位到html元素的左上角和右下角? - How can i position a background image to the top left and bottom right of a html element?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM