我打算將頁面拆分爲2列,有時左列會有溢出,而右列不會溢出。右列將是父母,左列是溢出的孩子。從父容器傳播滾動事件到子容器
.parentDiv
{
background-color: red;
}
.childDiv
{
background-color: green;
height: 100px;
width: 300px;
overflow-y: scroll;
overflow-x: scroll;
}
<div class="parentDiv">
scrolling in this area should scroll the inner overflow div <br>
scrolling in this area should scroll the inner overflow div <br>
scrolling in this area should scroll the inner overflow div <br>
scrolling in this area should scroll the inner overflow div <br>
scrolling in this area should scroll the inner overflow div <br>
scrolling in this area should scroll the inner overflow div <br>
<div class="childDiv">
this should scroll only form outside and inside<br>
this should scroll only form outside and inside<br>
this should scroll only form outside and inside<br>
this should scroll only form outside and inside<br>
this should scroll only form outside and inside<br>
this should scroll only form outside and inside<br>
this should scroll only form outside and inside<br>
this should scroll only form outside and inside<br>
this should scroll only form outside and inside<br>
v
this should scroll only form outside and inside<br>
</div>
</div>
我成立了一個類似的情景在這裏: http://jsfiddle.net/y1byh25d/1/
基本上,我想捕捉在紅色區域滾動事件,並造成綠色溢出容器滾動。這有點奇怪。
這非常聰明!我試圖找到一種方法來在溢出內部傳播事件並在父代中取消它,甚至沒有考慮簡單地在父代中捕獲它並使用js來滾動孩子。謝謝! – Costin