[英]jQuery height animation at the top, not the bottom of an element
HTML / CSS / JS: http : //jsfiddle.net/_mtr/XGe8d/2/
我的问题是动画发生在元素的底部,而不是顶部。 我认为这是我的CSS定位问题,但我无法理解它。 和想法?
尝试
$(document).ready(function() {
$("a").hover(
function() {
$(this).animate({
'paddingTop': '+=10px'
}), $(this).animate({
'paddingTop': '-=10px'
});
});
});
如果我理解你想要实现的目标,可以选择padding-top
而不是height
。
这是另一种解决方案
我更新了你的jsFiddle 。 我添加了位置:相对于你的css并使用了top()。 我还添加了.stop(true,true)来消除排队问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.