我打算将页面拆分为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