好吧,这个真的搞砸了。只需尝试在 JSfiddle 中运行以下命令。如果您在任何其他浏览器中尝试它,它都可以正常工作。如果您在 IE6 中运行它,它将无法运行。
如何在 IE6 上使用它?
此外,内容需要有 position:relative。
<style type="text/css">
.content {
position: relative;
}
.scrollable {
position: relative;
width: 200px;
height: 200px;
background: #333;
overflow: scroll;
}
.fixed {
position: fixed;
top: 180px;
width: 200px;
height: 20px;
background: #fa2;
}
</style>
<div class="scrollable">
<div class="content">
im scrollable<br><br>
im scrollable<br><br>
im scrollable<br><br>
im scrollable<br><br>
im scrollable<br><br>
im scrollable<br><br>
</div>
<div class="fixed">and I'm fixed</div>
</div>
最佳答案
position: fixed
在 IE6 上不工作。您可以使用 javascript 使 .fixed
转到其在窗口滚动和调整大小上的“固定”位置,但它看起来不太好(它会在 js 将其带回之前移动)
关于css - 在 IE6 中模拟可滚动 div 中的固定定位,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8884360/