javascript 当光标位于div边缘时如何滚动?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11222047/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to scroll when cursor is on the edge of div?
提问by Farhad-Taran
I have a div(menubar) that has a lot of links and these links are out of the view. I must make the div scroll to the right or left when the cursor is at the edge of the menu div, in order to bring these menu items into the view.
我有一个 div(menubar) 有很多链接,这些链接不在视图中。当光标位于菜单 div 的边缘时,我必须使 div 向右或向左滚动,以便将这些菜单项带入视图中。
I am a beginner with Jquery, so any help is greatly appreciated.
我是 Jquery 的初学者,因此非常感谢任何帮助。
回答by Vladimir Starkov
Short:
短的:
Use-ready solutions:
即用型解决方案:
Fullanswers you can read on relative questions:
您可以阅读有关相关问题的完整答案:
回答by BalaKrishnan?
Take a look at this example, in this example you can see how they scroll the div when the mouse at right edge of the div. you can do the same thing.
看一下这个例子,在这个例子中你可以看到当鼠标在 div 的右边缘时它们是如何滚动 div 的。你可以做同样的事情。
回答by Vinoth Kumar
Here Answer
这里回答
<div onmouseover="this.className='addscrool'" onmouseout="this.className='removescrool';" style="width:100px;height:100px;border:1px solid Blue">
</div>
<style>
.addscrool
{
overflow-y: scroll;
} .removescrool
{
overflow-y:hidden ;
}