2

我需要背景图像保持居中,因为我将在固定位置显示图表并希望货车(在图像中)始终可见。它在 Chrome 等中运行良好,但在 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>
4

1 回答 1

1

我的猜测是,虽然你div的身高是 100%,但那是 100% 的零。body也尝试将和元素都拉伸html到 100%,看看是否能解决问题。

body, html {
    height: 100%;
}

此外,正如 Adrift 所提到的,在 HTML 中添加适当的 DOCTYPE 会更好,否则 Internet Explorer 可能会以“怪癖模式”运行并让您感到困惑。

于 2013-03-17T15:26:21.917 回答