简体   繁体   English

拉伸IE7的div背景图片

[英]Stretching div background image for IE7

I'm stuck at making IE7 stretch background image for div, it does not support CSS3 background-size . 我被困在为div制作IE7拉伸背景图像,它不支持CSS3 background-size
Basically I need image fitting red area . 基本上我需要图像拟合红色区域

Div may have different height depending on content. Div的高度可能会有所不同,具体取决于内容。 That is why I had no luck with img faking background , I don't know how to set height. 这就是为什么我没有img伪造背景的运气,我不知道如何设置高度。

Can anybody please help me? 有人可以帮我吗?

A quick google search came up with (I haven't tested it, but Google is a lovely good friend): 谷歌进行了快速搜索(我还没有测试过,但是谷歌是一个很好的好朋友):

<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>

Edit: Derp. 编辑:德普。 Forgot the sample HTML 忘记了示例HTML

</head>

  <body>

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

  </body>
</html>

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

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

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