为IE7拉伸div背景图像

时间:2011-12-09 18:06:19

标签: html background internet-explorer-7 stretch css

我坚持为div做 IE7 拉伸背景图片,它不支持CSS3 background-size
基本上我需要image fitting red area

Div可能根据内容有不同的高度。这就是我img faking background没有运气的原因,我不知道如何设定身高。

有人可以帮助我吗?

1 个答案:

答案 0 :(得分:0)

快速谷歌搜索出现了(我没有测试过,但谷歌是一个可爱的好朋友):

<style type="text/css">
  html, body {
    height: 100%;
    margin: 0;
    padding: 0;
  }
  img#bg{
    position:fixed;
    top:0;
    left:0;
    width:100%;
    height:100%;
  }
  #content {
    position:relative;
    z-index:1;
  }
</style>

编辑:Derp。忘记样本HTML

</head>

  <body>

     <img src="size-bg.jpg" alt="background image" id="bg" />
     <div id="content">Your website content.</div>

  </body>
</html>

链接自:http://dipaksblogonline.blogspot.com/2011/01/ie-78-stretching-background-image-to.html

相关问题