JQuery animation height at the top, not the bottom of the element

HTML / CSS / JS here: http://jsfiddle.net/_mtr/XGe8d/2/

My problem is that the animation happens at the bottom of the element, not the top. I believe this is a problem with my CSS positioning, but I can't judge it. And ideas?

+4
source share
4 answers

here is another solution

http://jsfiddle.net/moeishaa/s26wr/

+1
source

Try

$(document).ready(function() { $("a").hover( function() { $(this).animate({ 'paddingTop': '+=10px' }), $(this).animate({ 'paddingTop': '-=10px' }); }); }); 
+2
source

If I understand what you are trying to achieve, one option is to animate the padding-top instead of height .

+2
source

I updated your jsFiddle . I added a position: relative to your css and used top (). I also added .stop (true, true) to fix the queue problems.

0
source

Source: https://habr.com/ru/post/1346767/


All Articles