【发布时间】:2012-09-21 04:52:18
【问题描述】:
我想在我的网站上放一张图片,当你将鼠标悬停在它上面时,图片会向下滑动并显示其背后的文字。
我已经让这个工作了,但是如果我在图像上稍微移动鼠标,它会再次移动。
这里是 jQuery 代码:
$(document).ready(function(){
$('.show').hover(function(){
$(this).animate({top:'400px'});
},function(){
$(this).animate({top:'0px'});
});
});
这是css:
.hover {
width: 300px;
height: 400px;
background: black;
margin-top: 10px;
overflow: hidden;
position: relative;
}
.show {
width: 300px;
height: 400px;
background: red;
position: absolute;
}
有没有办法让它在悬停状态下停止,直到鼠标完全移出 div?
这里是请求的 JSFiddle JSFIDDLE
【问题讨论】:
-
cat you une fiddle so we can see how it works with html
-
添加了我的答案,还有小提琴! :)