防止身体在mouswheel上滚动,但不能在texarea上滚动 [英] Prevent body from scrolling on mouswheel, but not the texarea

查看:198
本文介绍了防止身体在mouswheel上滚动,但不能在texarea上滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是一个示例:
http://jsfiddle.net/cB3jZ/15/



当您使用鼠标滚轮滚动到textarea的底部时,它会继续滚动页面的其余部分..如何防止这种情况? p>

当我鼠标悬停textarea时,我可以使用这个脚本禁用滚动:
http://stackoverflow.com/a/4770179/973485
但我仍然希望textarea可以滚动。



http://jsfiddle.net/cB3jZ/15/



希望你能帮助! :=)

解决方案

我发现如果外部容器是body标签,它只继续滚动。所以,如果你这个工作!

 < style> 
body,html {height:100%;}
#fakeBody {height:100%; overflow:auto;}
< / style>
< body>
< div id =fakeBody>
<! - 弹出一个textarea里面 - >
< / div>
< / body>

http://jsfiddle.net/cB3jZ/34/


Here is an example: http://jsfiddle.net/cB3jZ/15/

When you scroll to the bottom of the textarea with your mousewheel, it continues to scroll the rest of the page.. How can i prevent that!?

When i mouseover the textarea i could disable scrolling intierly with this script: http://stackoverflow.com/a/4770179/973485 But i still want the textarea to be scrollable.

http://jsfiddle.net/cB3jZ/15/

Hope you can help! :=)

解决方案

I found out the it only continues scrolling if the outer container if it is the body tag. So if you this it works!

<style>
   body,html {height:100%;}
   #fakeBody {height:100%; overflow:auto;}
</style>
<body>
<div id="fakeBody">
    <!-- popup with a textarea inside -->
</div>
</body>

http://jsfiddle.net/cB3jZ/34/

这篇关于防止身体在mouswheel上滚动,但不能在texarea上滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆