我正在创建一个示例,其中我们将有四个块,当有人在这个块上滑动显示它背后的内容时,当鼠标退出事件发生时,它就会滑落下来。我就是这样做的:
$(".garage span").hover(function(){
$(this).animate({'height':'0px'},1000);
//$(this).clearQueue().animate({'height':'0px'},1500);
}, function() {
$(this).animate({'height':'100px'},1000);
//$(this).clearQueue().animate({'height':'100px'},1500);
});
<ul class="garage">
<li id="shutter1"><span>1</span></li>
<li id="shutter2"><span>2</span></li>
<li id="shutter3"><span>3</span></li>
<li id="shutter4"><span>4</span></li>
</ul>
问题是动画不愿停止。原因是当滑块滑动时,它会自动触发鼠标退出事件,但是如何阻止它呢?
另外,让我知道,如果我应该为它提出另一个问题,我想有一些文字的跨度。我不是很好的css,所以请帮助我在这方面。
发布于 2010-11-02 00:01:22
$(".garage li").hover(function(){
$("span", this).animate({'height':'0px'},1000);
}, function() {
$("span", this).animate({'height':'100px'},1000);
});
发布于 2010-11-02 00:00:48
你应该把悬停放在Li元素上,而不是跨度上。这样,即使跨度缩小,你的模式仍然在黎族地区。只要确保你的李有一个高度,留出空间,鼠标有一个悬停区域后,跨度缩小。
https://stackoverflow.com/questions/4075769
复制相似问题