你可以使用一个很好的老式img标签,没有高度和宽度属性.在CSS中,使用低z-index绝对定位,将高度和宽度设置为"100%".
将页面上的其他内容放在另一个具有更高z-index的div中
像这样:
<style type="text/css">
#stretchy {
postion: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
z-index: 0;
}
#everything_else {
position: relative;
top: 0;
left: 0;
z-index: 10;
}
</style>
...
<img src="/images/myimage.jpg" id="stretchy" />
<div id="everything_else">
...
</div>
Run Code Online (Sandbox Code Playgroud)
有关示例,请参见http://axoplasm.com/lost.html.
它不完全是一个"背景图像"(可能不符合符合W3C标准的CSS),但它确实有效.