垂直拉伸背景图像
问题描述:
我试图弄清楚如何垂直拉伸背景图像.我通过以下方式将CSS3与3张图片一起使用:
I am trying to figure out how to stretch a background image vertically. I am using CSS3 with 3 images in the following way:
background-image: url("left.png"), url("right.png"), url("center.png")
background-repeat: no-repeat, no-repeat, repeat-x
background-position: top left, top right, top
现在,我想垂直拉伸这些图像,使其一直延伸到底部.有办法吗?
Now I want to stretch these images vertically to that they extend all the way to the bottom. Is there a way to do this?
答
我在这里参加聚会很晚,但这对我有用:
I'm late to the party here, but this is what worked for me:
background-size: auto 100%;
这将垂直适合图像,并让宽度做任何需要做的事情(我认为默认情况下会重复).您还可以设置:
This will fit the image vertically and let the width do whatever it needs to do (i think it repeats by default). You can also set:
background-repeat: no-repeat;
不要在水平方向上重复图像.
for it to not repeat the image in the horizontal direction.