0
我被困在製作IE7爲div拉伸背景圖像,它不支持CSS3 background-size
。
基本上我需要image fitting red area。爲IE7拉伸div背景圖像
Div根據內容可能有不同的高度。這就是爲什麼我沒有與img faking background運氣,我不知道如何設置高度。
任何人都可以幫我嗎?
我被困在製作IE7爲div拉伸背景圖像,它不支持CSS3 background-size
。
基本上我需要image fitting red area。爲IE7拉伸div背景圖像
Div根據內容可能有不同的高度。這就是爲什麼我沒有與img faking background運氣,我不知道如何設置高度。
任何人都可以幫我嗎?
一個快速谷歌搜索想出了(我沒有測試過,但谷歌是一個可愛的好朋友):
<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
謝謝!我看到了這一個。它爲整個頁面繪製背景,但我只需要它爲div。這裏[http://i.stack.imgur.com/gql45.jpg](http://i.stack.imgur.com/gql45.jpg)就是例子。我的問題是高度:100%的圖片使得div太大。 – Xeon
如何將圖片大小調整爲所需的大小,然後將其設置爲僅用於div的背景網址?當然,這是一個破解解決方案... – Gobbledigook
Yeap,我這樣做。我用'display:none'樣式放了'img'。然後在文檔準備就緒的情況下,我將圖像大小調整爲div大小並設置「display:block」。骯髒但工作的解決方案:) – Xeon