2011-06-22 79 views
1

通常IE不支持CSS3 background-size,我正在寻找解决方法。替代背景大小?

我尝试把图像作为第一件事情在页面上设置CSS,如:

#bg_stretch { 
    position: absolute; 
    top: 0; 
    left: 0; 
    z-index: -10; 
    width: 100%; 
} 

做工不错宽明智的,但加入了height: 100%不能正常工作,使其覆盖的长度页。

+0

确保您已为'html'和'body'定义了一个高度,以及其他任何可能包含图像的高度。 – BoltClock

回答

1

你在找?

http://jsfiddle.net/VMzFB/

CSS:

#stretch { 
    position: fixed; 
    top: 0; 
    left: 0; 
    right: 0; 
    bottom: 0; 
    z-index: -10; 

    /* only ie7 needs this */ 
    height: 100%; 
} 
#stretch img { 
    width: 100%; 
    height: 100%; 
    display: block 
} 

HTML:

<div id="stretch"> 
    <img src="http://dummyimage.com/256x256/f0f/fff" /> 
</div> 

如果这是不完全正确,看看这里的想法:

http://css-tricks.com/3458-perfect-full-page-background-image/

+0

非常感谢! – Brett

0

尝试将bottom:0;添加到该CSS规则。