css:
* {
margin: 0;
}
html, body {
height: 100%;
overflow: auto;
}
.wrapper {
position: relative;
width: 100%;
height: 100%;
overflow: auto;
}
.box {
position: fixed;
left: 10px;
top: 180px;
}
* html .box {
position: absolute;
}
html:
<html>
<head>
<link rel="stylesheet" href="layout.css" ... />
</head>
<body>
<div class="wrapper">
<p>All of your website content should be here.</p>
</div>
<div class="box">
<p>This box is fixed.</p>
</div>
</body>
</html>
上面的代码的关键代码是:
html,body{overflow:auto; height:100%;};
* html .box {position: absolute; };/*注意:这段代码要放在position:fixed之后才其作用*/
加上这两段代码就能修复bug。
原文链接:http://ryanfait.com/resources/fixed-positioning-in-internet-explorer/