jQuery 动画无法在悬停时工作

标签 jquery css hover jquery-animate

把我的头发拉出来,看起来很简单,但无论出于何种原因都行不通。

当您使用 jquery 将鼠标悬停在父元素上时,我正在尝试为元素中的 div 容器设置动画。

想法是,当您将鼠标悬停在父级上时,子级 div 会向下滑动,而当您将鼠标悬停在父级上时,它会移回原来的位置。

这是我的 html 标记:

<article class="skizzar_masonry_entry " style="position: absolute; left: 0px; top: 0px;">

<a class="skizzar_ma_fancybox clickable" href="http://www.skizzar.com/paulthefunkydrummer/files/2015/01/paul_jones_drummer_gallery_16-683x1024.jpg">
    <i class="skizzar_ma_overlay fa fa-search" style="top: 0px;"></i>
    <img alt="Paul Jones" src="http://www.skizzar.com/paulthefunkydrummer/files/2015/01/paul_jones_drummer_gallery_16-683x1024.jpg"></img>
</a>

</article>

和我的 jQuery:

$(".skizzar_masonry_entry").hover(function(){
$('.skizzar_ma_overlay', this).animate({'top': '100px'}, 400, 'easeOutExpo');
}, function(){
$('.skizzar_ma_overlay', this).animate({'top': '0'}, 400, 'easeOutExpo');
}); 

这是一个展示我工作的 jsfiddle: http://jsfiddle.net/h3sqe9re/

最佳答案

您需要为自定义转换包含 jQuery-UI。 easeOutExpo 未包含在 jQuery 核心库中。

working demo

Easing

The remaining parameter of .animate() is a string naming an easing function to use. An easing function specifies the speed at which the animation progresses at different points within the animation. The only easing implementations in the jQuery library are the default, called swing, and one that progresses at a constant pace, called linear. More easing functions are available with the use of plug-ins, most notably the jQuery UI suite.

关于jQuery 动画无法在悬停时工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28023226/

相关文章:

html - 禁用跨度悬停

php - 将 javascript 值传输到 php 变量

html - Firefox 内联列表中的标签和输入/选择对齐方式

html - 如何在 Angular 7 上延迟显示点击表单?

css - DIV 周围图像(可能很简单的答案)

qt - 更改平面 QPushButton 悬停状态的样式(不使用样式表)

html - 使用 CSS 在悬停时更改父和子 div

javascript - 如何使用 jquery 和 wp_enqueue_script

jquery - 提取下个月/上个月的数据

javascript - 如何在不点击图片的情况下将图片翻转回来?