Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我目前正在开发一个网站的前端,它是单页,在 div 之间平滑滚动。
我想禁用鼠标本身的滚动。
我知道overflow:hidden;删除滚动条,但是,我希望页面仅在他们单击所需 div 的链接时滚动。正确的方法是什么?
overflow:hidden;
试试这个:
<script type="text/javascript"> if(window.addEventListener){ window.addEventListener('DOMMouseScroll',wheel,false); } function wheel(event) { event.preventDefault(); event.returnValue=false; } window.onmousewheel=document.onmousewheel=wheel; </script>