2013-03-17 71 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