简体   繁体   English

拉伸背景图片

[英]stretching background image

I have a background image with size 1x947 px , 我有一个尺寸为1x947 px的背景图片,

the problem is it's a gradient color , so i only use repeat-x , but when the page height over 947 px , it shows it background color, 问题是它是渐变色 ,所以我只使用repeat-x ,但是当页面高度超过947 px时 ,它显示为背景色,

background-image:url(bg.gif);
background-repeat:repeat-x;

how to stretch it ? 如何伸展呢

在此处输入图片说明

here's the code example on fiddle http://jsfiddle.net/K9cUd/1/ 这是小提琴上的代码示例http://jsfiddle.net/K9cUd/1/

Hard to tell without the code or an example. 没有代码或示例很难说。

You could use CSS3's 您可以使用CSS3

background-size: 100%;

which should stretch it to the entire page size. 应该将其扩展到整个页面大小。

You might need to do 您可能需要做

background-size: 0 100%; or background-size: 0% 100%; background-size: 0% 100%;

so the width does not change. 因此宽度不会改变。

You can read more here: http://webdesign.about.com/od/styleproperties/p/blspbgsize.htm 您可以在此处阅读更多信息: http : //webdesign.about.com/od/styleproperties/p/blspbgsize.htm

And the spec: http://www.w3.org/TR/css3-background/#the-background-size 规格: http//www.w3.org/TR/css3-background/#the-background-size

如果您不想使用百分比,请使用:

    background-size: cover;

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

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