<bdo id='z9Jly'></bdo><ul id='z9Jly'></ul>
<i id='z9Jly'><tr id='z9Jly'><dt id='z9Jly'><q id='z9Jly'><span id='z9Jly'><b id='z9Jly'><form id='z9Jly'><ins id='z9Jly'></ins><ul id='z9Jly'></ul><sub id='z9Jly'></sub></form><legend id='z9Jly'></legend><bdo id='z9Jly'><pre id='z9Jly'><center id='z9Jly'></center></pre></bdo></b><th id='z9Jly'></th></span></q></dt></tr></i><div id='z9Jly'><tfoot id='z9Jly'></tfoot><dl id='z9Jly'><fieldset id='z9Jly'></fieldset></dl></div>
  • <small id='z9Jly'></small><noframes id='z9Jly'>

      1. <tfoot id='z9Jly'></tfoot>
      2. <legend id='z9Jly'><style id='z9Jly'><dir id='z9Jly'><q id='z9Jly'></q></dir></style></legend>

        如何防止鼠标在悬停元素之外滚动?

        时间:2023-11-29

        <small id='jtEX9'></small><noframes id='jtEX9'>

              <tbody id='jtEX9'></tbody>

              <tfoot id='jtEX9'></tfoot><legend id='jtEX9'><style id='jtEX9'><dir id='jtEX9'><q id='jtEX9'></q></dir></style></legend>

              <i id='jtEX9'><tr id='jtEX9'><dt id='jtEX9'><q id='jtEX9'><span id='jtEX9'><b id='jtEX9'><form id='jtEX9'><ins id='jtEX9'></ins><ul id='jtEX9'></ul><sub id='jtEX9'></sub></form><legend id='jtEX9'></legend><bdo id='jtEX9'><pre id='jtEX9'><center id='jtEX9'></center></pre></bdo></b><th id='jtEX9'></th></span></q></dt></tr></i><div id='jtEX9'><tfoot id='jtEX9'></tfoot><dl id='jtEX9'><fieldset id='jtEX9'></fieldset></dl></div>
                <bdo id='jtEX9'></bdo><ul id='jtEX9'></ul>
                  本文介绍了如何防止鼠标在悬停元素之外滚动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个设置为溢出的 div:scroll;.我得到了我想要的滚动条.但是,当使用鼠标滚轮滚动 div 时,它会在到达 div 内容的顶部或底部时滚动页面的其余部分.

                  I have a div which is set to overflow:scroll;. I get scrollbars which is what I want. However when scrolling the div with the mousewheel it scrolls the rest of the page when it reaches the top or bottom of the div's content.

                  如何根据悬停的内容仅滚动 div 或整个页面?

                  How can I scroll only the div or the entire page based on what's hovered ?

                  推荐答案

                  首先我不认为你可以覆盖滚动事件.所以这就是我要做的.我不知道 jquery,但这里有一些直接的 javascript.

                  First I don't think you can override the scroll event. So here is what I would do. I don't know jquery but here is some straight javascript.

                  document.getElementById('scrollDiv').onmouseover=function(){
                    document.getElementByTagName('body')[0].style.overflow='hidden';
                  }
                  document.getElementById('scrollDiv').onmouseout=function(){
                    document.getElementByTagName('body')[0].style.overflow='';
                  }
                  

                  显然你可以稍微调整一下,但这是基本的想法.此外,如果您需要,您可以执行其他测试用例.就像如果 div 有焦点然后做同样的事情.取决于您的设置.

                  Obviously you could tweak this a little, but this is the basic idea. Also, if you need to you could do other test cases. Like if the div has focus then do the same thing. Depends on your setup.

                  这篇关于如何防止鼠标在悬停元素之外滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:循环 div 和缩略图 下一篇:在悬停时显示特定的div?仅使用 css 和 html

                  相关文章

                    <bdo id='H1zGE'></bdo><ul id='H1zGE'></ul>
                • <tfoot id='H1zGE'></tfoot>

                    <i id='H1zGE'><tr id='H1zGE'><dt id='H1zGE'><q id='H1zGE'><span id='H1zGE'><b id='H1zGE'><form id='H1zGE'><ins id='H1zGE'></ins><ul id='H1zGE'></ul><sub id='H1zGE'></sub></form><legend id='H1zGE'></legend><bdo id='H1zGE'><pre id='H1zGE'><center id='H1zGE'></center></pre></bdo></b><th id='H1zGE'></th></span></q></dt></tr></i><div id='H1zGE'><tfoot id='H1zGE'></tfoot><dl id='H1zGE'><fieldset id='H1zGE'></fieldset></dl></div>
                  1. <legend id='H1zGE'><style id='H1zGE'><dir id='H1zGE'><q id='H1zGE'></q></dir></style></legend>

                  2. <small id='H1zGE'></small><noframes id='H1zGE'>