简体   繁体   English

允许背景图片展开

[英]Allow background image to expand

I want to give a container a background image, which is basically a white image, with a fancy border on its left and right side. 我想给一个容器一个背景图像,它基本上是一个白色图像,在其左右两侧都带有花哨的边框。 It is only a few pixels high so gets repeated on the y-axis. 它只有几个像素高,因此会在y轴上重复出现。

However, the image is a set width, so cannot expand/contract on the x-axis. 但是,图像是设定的宽度,因此无法在x轴上扩展/收缩。 Is there a way of maybe giving the container 3 background images - 1 for the left border, 1 for the right and 1 for the centre? 有没有办法给容器提供3个背景图像-左侧边框1个,右侧边框1个,中间1个?

That way I can repeat the centre background image and sandwich it between the side background images. 这样,我可以重复中心背景图像并将其夹在侧面背景图像之间。

#container{
background-image: url(image1.png), url(image2.png), url(image3.png);
background-position: left top, right top, center top;
}

I had two images and did it with that you can add another one http://jsfiddle.net/xksr01v4/ 我有两张图片,并用它添加了一个图片http://jsfiddle.net/xksr01v4/

#back{
   width: 500px;
   height: 250px;
   background-image: url(http://placekitten.com/300/301),
 url(http://static.comicvine.com/uploads/original/11112/111123678/3503035-3468468-2718720139-  batma.jpg);
   background-position: left, right;
   background-repeat: no-repeat;
}

可能有很多方法可以执行此操作,但是此链接显示了具有扩展背景图像的非常简单的方法:

background-size: 100% auto;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM