- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我有一个高度和宽度有限的 div,其中的内容超过了 div 的大小。所以我在 div 的顶部和底部放置了两个图像,我希望内容相对于我悬停的图像上下滚动。我已经设法获得悬停但它不受控制,即使我将鼠标从图像上移开它也会一直持续到最后。因此,我希望一旦我将鼠标移开就停止滚动,当我再次将鼠标悬停在图像上时,我希望滚动从它停止的地方恢复。 jsfiddle
HTML:
<div id="hover"> HOVER ME </div>
<div id="container">
The Mauritius Blue Pigeon is an extinct species of blue pigeon formerly endemic to the Mascarene island of Mauritius in the Indian Ocean east of Madagascar. It has two extinct relatives from the Mascarenes and three extant ones from other islands. It had white hackles around the head, neck and breast and blue plumage on the body, and it was red on the tail and the bare parts of the head. These colours were thought similar to those of the Dutch flag, a resemblance reflected in some of the bird's names. It was 30 cm (12 in) long and larger and more robust than any other blue pigeon species. It could raise its hackles into a ruff, which it used for display. Its call sounded like "barf barf" and it also made a cooing noise. It fed on fruits, nuts, and molluscs, and was once widespread in the forests of Mauritius. The bird was first mentioned in the 17th century and was described several times thereafter, but very few accounts describe the behaviour of living specimens. Several stuffed and at least one live specimen reached Europe in the 1700s and 1800s. Only three stuffed specimens exist today, and only one bird was ever depicted when alive. The species is thought to have become extinct in the 1830s due to deforestation and predation. (Full article...)
Recently featured: Action of 1 January 1800 – Terang Boelan – Muckaty Station............................................................................................................................................................................
The Mauritius Blue Pigeon is an extinct species of blue pigeon formerly endemic to the Mascarene island of Mauritius in the Indian Ocean east of Madagascar. It has two extinct relatives from the Mascarenes and three extant ones from other islands. It had white hackles around the head, neck and breast and blue plumage on the body, and it was red on the tail and the bare parts of the head. These colours were thought similar to those of the Dutch flag, a resemblance reflected in some of the bird's names. It was 30 cm (12 in) long and larger and more robust than any other blue pigeon species. It could raise its hackles into a ruff, which it used for display. Its call sounded like "barf barf" and it also made a cooing noise. It fed on fruits, nuts, and molluscs, and was once widespread in the forests of Mauritius. The bird was first mentioned in the 17th century and was described several times thereafter, but very few accounts describe the behaviour of living specimens. Several stuffed and at least one live specimen reached Europe in the 1700s and 1800s. Only three stuffed specimens exist today, and only one bird was ever depicted when alive. The species is thought to have become extinct in the 1830s due to deforestation and predation. (Full article...)
Recently featured: Action of 1 January 1800 – Terang Boelan – Muckaty Station............................................................................................................................................................................
</div>
<div id="hover2"> HOVER ME </div>
CSS:
#hover{
width:200px;
height:20px;
border:1px solid #cc0000;
}
#hover2{
width:200px;
height:20px;
border:1px solid #cc0000;
}
#container{
width:500px;
height:300px;
overflow-y:auto;
border:1px solid #000;
overflow: hidden;
}
#container div{
width:100px;
height:100px;
float:left;
}
JavaScript:
$('#hover').hover(function(){
$('#container').animate({ scrollTop: $('#container')[0].scrollHeight }, 1000);
});
$('#hover2').hover(function(){
$('#container').animate({ scrollTop: 0 }, 1000);
});
最佳答案
您需要一次制作一点动画..
var amount = '';
function scroll() {
$('#container').animate({
scrollTop: amount
}, 100, 'linear', function() {
if (amount != '') {
scroll();
}
});
}
$('#hover').hover(function() {
amount = '+=10';
scroll();
}, function() {
amount = '';
});
$('#hover2').hover(function() {
amount = '-=10';
scroll();
}, function() {
amount = '';
});
#hover {
width: 200px;
height: 20px;
border: 1px solid #cc0000;
}
#hover2 {
width: 200px;
height: 20px;
border: 1px solid #cc0000;
}
#container {
width: 500px;
height: 300px;
overflow-y: auto;
border: 1px solid #000;
overflow: hidden;
}
#container div {
width: 100px;
height: 100px;
float: left;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="hover"> HOVER ME </div>
<div id="container">
The Mauritius Blue Pigeon is an extinct species of blue pigeon formerly endemic to the Mascarene island of Mauritius in the Indian Ocean east of Madagascar. It has two extinct relatives from the Mascarenes and three extant ones from other islands. It
had white hackles around the head, neck and breast and blue plumage on the body, and it was red on the tail and the bare parts of the head. These colours were thought similar to those of the Dutch flag, a resemblance reflected in some of the bird's
names. It was 30 cm (12 in) long and larger and more robust than any other blue pigeon species. It could raise its hackles into a ruff, which it used for display. Its call sounded like "barf barf" and it also made a cooing noise. It fed on fruits, nuts,
and molluscs, and was once widespread in the forests of Mauritius. The bird was first mentioned in the 17th century and was described several times thereafter, but very few accounts describe the behaviour of living specimens. Several stuffed and at
least one live specimen reached Europe in the 1700s and 1800s. Only three stuffed specimens exist today, and only one bird was ever depicted when alive. The species is thought to have become extinct in the 1830s due to deforestation and predation. (Full
article...) Recently featured: Action of 1 January 1800 – Terang Boelan – Muckaty Station............................................................................................................................................................................
The Mauritius Blue Pigeon is an extinct species of blue pigeon formerly endemic to the Mascarene island of Mauritius in the Indian Ocean east of Madagascar. It has two extinct relatives from the Mascarenes and three extant ones from other islands. It
had white hackles around the head, neck and breast and blue plumage on the body, and it was red on the tail and the bare parts of the head. These colours were thought similar to those of the Dutch flag, a resemblance reflected in some of the bird's
names. It was 30 cm (12 in) long and larger and more robust than any other blue pigeon species. It could raise its hackles into a ruff, which it used for display. Its call sounded like "barf barf" and it also made a cooing noise. It fed on fruits, nuts,
and molluscs, and was once widespread in the forests of Mauritius. The bird was first mentioned in the 17th century and was described several times thereafter, but very few accounts describe the behaviour of living specimens. Several stuffed and at
least one live specimen reached Europe in the 1700s and 1800s. Only three stuffed specimens exist today, and only one bird was ever depicted when alive. The species is thought to have become extinct in the 1830s due to deforestation and predation. (Full
article...) Recently featured: Action of 1 January 1800 – Terang Boelan – Muckaty Station............................................................................................................................................................................
</div>
<div id="hover2"> HOVER ME </div>
关于javascript - 将鼠标悬停在图像上时以受控方式滚动 div 内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14122555/
这个问题已经有答案了: How do I attach events to dynamic HTML elements with jQuery? [duplicate] (8 个回答) How to
我通常从问题代码开始写 git 注释,像这样: #3533: Fixed VIB (Very Important Bug) 当我从命令行执行提交时,我写 git commit -a -m "#3533
以下命令构建我的函数并将其发布到 Azure。但它总是在 Debug模式下构建 - 如何使其切换到在 Release模式下构建? func azure functionapp publish NAME
我需要在 virtualenv 中以 sudo 身份运行 python 脚本。但是,运行 sudo python 将运行全局 python 解释器,而不是来自 virtualenv 的解释器。 有办法
我想制作一个自定义按钮并在自定义按钮类内的选择器内提供输入,但它给我一个错误消息。我该如何修复它 我在 Playground 上测试它,因为当我运行到模拟器时应用程序崩溃了。这是 Playground
我是 Angular 的新手,ng-repeat 对我不起作用。 我的第一个 ng-repeat 有效,但我使用 json 字符串的第二个无效。它提示 ng-repeat dupes 但我不明白为什么
每当麦克风听到打响指的声音时,我都会尝试加 1。 var sketch = function (p) { with(p) { var mic; va
我在 ng build --prod 时遇到堆内存不足错误,是否有任何解决方法。当 --aot=false 时它的构建很好。 有什么想法吗? 最佳答案 尝试通过以下脚本在 json 包中运行构建脚本:
我正在尝试部署一个rest api,而不涉及任何类型的UI/html 文件。我只是想让它响应一些 json 响应主体,仅此而已。我使用 spring 和 java 11。此请求在 localhost
我正在使用 Tomcat 运行一个 Java 网络应用程序,我有我的 Java 类和 .jsp 文件呈现网络。我正在尝试实现一项功能,您可以在其中搜索文件中的关键字,然后返回文件,以便用户可以从网页上
我正在尝试实现一个由 Spring 提供支持的服务器发送事件 (SSE) 网页。我的测试代码执行以下操作: 浏览器使用 EventSource(url) 连接到服务器。 Spring 接受带有以下 C
我正在使用 Visual Studio Code 中的远程 SSH 扩展连接到 Azure 中的虚拟机。问题是我不能以 root 身份 ssh,但需要 root 权限来编辑/etc 文件夹中的某些文件
我们有一个作为 Windows 服务安装的 C# 控制台应用程序。目标 64 位计算机运行的是 Windows Server 2012。我们使用了 64 位 installutil 实用程序: C:\
我的计算机上安装了 VS2010 和 VS2012,并安装了 .NET Framework 4.0,然后我将其升级到 .NET Framework 4.5。但是,我仍在开发需要在 .NET Frame
我正在使用 Express 在 NodeJs 之上用 javascript 编写 CMS。我的目标是构建我在过去几年中每天都在 .NET 中构建的东西,但现在完全是在 javascript 中构建的。
我有以下 docker-compose.yml 文件: version: "3.3" services: api: build: ./api expose: - '80
如何在将数据插入到 Db 时以 asp.net mvc4 形式自动生成 GUID 我需要将 GUID 数据类型添加到我的表中,并且需要在提交其他数据时自动插入 16 位值 最佳答案 请检查以下链接..
我正在使用时刻时区,因此我可以从选定的时区转换为客户端的时区。 我无法以比这更好的方式实现它: convertSelectedTimeZoneToClients() { let timeZon
这个问题在这里已经有了答案: Empty body in fetch POST request (5 个回答) 3年前关闭。 在我的 React 应用程序中,当我提交表单以创建新用户时,我使用 fet
ngRouteProvider依赖注入(inject)出错可能是什么原因 注意:$location依赖于ngRoute,这就是为什么我需要注入(inject)它,而我并没有真正使用它,而只是使用$lo
我是一名优秀的程序员,十分优秀!