jQuery动画边距顶 [英] jQuery animate margin top
问题描述
我在jsfiddle上有一个脚本: http://jsfiddle.net/kX7b6/
I have a script on jsfiddle: http://jsfiddle.net/kX7b6/
悬停时不显示任何内容
悬停时我想要绿色框与红色框重叠, 。没有发生任何事情。
On hover I want the green box to overlap the red box with a negative margin -50px. Nothing happens.
动画可以工作,但不是边距
The animation works, but not margin
动画本身是工作我添加了不透明度的功能到动画。
Just to show that the animation itself is working i added a opacity function to the animation. margin-top is set to 0px inline as far as I can see.
推荐答案
您已经拥有 MarginTop
而不是 marginTop
如果你离开中间动画,这也是很麻烦的,这里是更新:
It is also very buggy if you leave mid animation, here is update:
请注意,我将其更改为 mouseenter
和 mouseleave
因为我不认为当您将鼠标悬停在红色或绿色区域时,意图是取消动画。
Note I changed it to mouseenter
and mouseleave
because I don't think the intention was to cancel the animation when you hover over the red or green area.
这篇关于jQuery动画边距顶的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!