[英]How to scroll a larger div in an overflow:hidden div
I have the following structure: 我有以下结构:
<div id="start">
<div id="largediv">
<div id="ball"></div>
</div>
</div>
The div start has for example fixed height and width like 500px x 500px
and the div largediv
has 1000px x 1000px
. 例如,div开始具有固定的高度和宽度,例如
500px x 500px
,而div largediv
具有largediv
1000px x 1000px
largediv
。 I can move the ball in the 500x500px area but I don't know how to scroll so I can change the position in the largediv
. 我可以将球移动到500x500px的区域,但是我不知道如何滚动,因此可以更改
largediv
的位置。 Another thing is that the start div has overflow hidden. 另一件事是start div隐藏了溢出。 Here is the jsfiddle http://jsfiddle.net/zander_pope/xd4fb1nz/
这是jsfiddle http://jsfiddle.net/zander_pope/xd4fb1nz/
You can use jQuery mousewheel
function. 您可以使用jQuery
mousewheel
功能。
$("#start").on("mousewheel", function(e){
var scrollTop = $(this).scrollTop(),
scrollLeft = $(this).scrollLeft();
$(this).scrollTop(scrollTop+(e.originalEvent.deltaY));
$(this).scrollLeft(scrollLeft+(e.originalEvent.deltaX));
return false;
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.