我想有一個固定位置的div與溢出-y:滾動,這意味着我希望div留在原地,而其餘的內容正常滾動。 而我無法弄清楚什麼是錯的,有人能幫忙嗎?在此先感謝...固定位置div內pos:相對&溢出-y:滾動
.foo {
position:relative;
display:block;
width:100%;
height:300px;
overflow-y:scroll;
}
.bar {
position:fixed;
top:0;
right:0;
}
這裏是HTML
<div class="foo">
<div class="bar"><div><!-- end of div that should be fixed -->
<div class="someOther">...</div>
<div class="someOther">...</div>
<div class="someOther">...</div>
<div class="someOther">...</div>
</div><!-- end of container -->
固定元素的位置相對於整個頁面而不是它的父元素。 – 2013-04-26 16:28:36