如何製作一個div讓頁面滾動,但只在頁面的某個區域滾動?只在某個地方製作一個div頁面滾動頁面?
我不能解決如何使用CSS做到這一點只有一部分的頁面,我認爲JavaScript可能是唯一的選擇。
例如,有一頁的三個部分,頂部,中間和底部。
有一個正確的浮動DIV應該在中間部分用戶滾動和停止滾動的中間部分的頂部還有中間部分的底部被「留在原地」。
#Top {
background-color: grey;
width: 100%;
height: 400px;
}
#Middle {
background-color: green;
width: 100%;
height: 800px;
}
#Bottom {
background-color: blue;
width: 100%;
height: 400px;
}
#scrolling-section {
background-color: yellow;
width: 30%;
height: 150px;
float: right;
}
<div id="Top">
</div>
<div id="Middle">
<div id="scrolling-section">
This box should scroll along the green section but 'cut-off' and stop scrolling at the top and bottom of the green section
</div>
</div>
<div id="Bottom">
</div>
的jsfiddle:fiddle
嗨,你將需要JavaScript,如果你正在使用Bootstrap有afix這是在javascript部分下,否則你將需要可能的代碼自定義。 –