2013-03-17 70 views
2

我需要背景圖像保持居中,因爲我要在固定位置顯示圖表,並且希望圖像中的貨車始終可見。它在Chrome等工作正常,但沒有出現在IE8中。我的div背景圖像在IE8中不顯示

http://clients.online95.com/RzMaOxkMOC/rep_mktsh.php

謝謝您可以提供任何幫助。

#aa_breakdown_bg { 
background: url(/RzMaOxkMOC/images/aa_breakdown_bg.jpg) center top no-repeat fixed; 
overflow: hidden; 
height: 100%; 
} 


<html lang="en"> 
<head> 
    <title>UK Breakdown Market Tracker</title> 
    <meta http-equiv="X-UA-Compatible" content="IE=9" /> 
    <script type="text/javascript"> 
     window.history.forward(); 
     function noBack() { window.history.forward(); } 
    </script> 
</head> 
<body onload="noBack();" onpageshow="if (event.persisted) noBack();" onunload=""> 

<div id="aa_breakdown_bg"></div> 

</body> 
</html> 
+0

我發現了一個非常簡單的解決方案 - 只需在css中添加一個最小高度 - 爲什麼我不能在4個小時前嘗試過呢! – 2013-03-17 15:35:07

回答

1

我的猜測是,雖然你的div是100%的高度,這是100%的零。嘗試將bodyhtml元素同時拉伸至100%,然後查看這是否有效。

body, html { 
    height: 100%; 
} 

此外,作爲漂泊提到,你會好很多關添加適當的DOCTYPE到HTML,否則Internet Explorer將在「quirks mode」大概跑,真的迷惑你。

+1

身高是問題,我有身高:100%,但在零的100%仍然是零 - 所以增加一個最小高度,並解決了我的問題。 – 2013-03-17 15:38:56