Sunday, 15 August 2010

javascript - Jquery animate position is not working with margin-top? -



javascript - Jquery animate position is not working with margin-top? -

i created jsbin has div labels

and want scroll specific label.

however working correctly if margin-top 0.

however if test margin-top:100px not accurate... http://jsbin.com/idinob/8/edit

why ?

the animate command :

$('.d').animate({ scrolltop: $(".s210").position().top }, 200); });

and did utilize position , not offset because im talking span inside div. talking position , not offset.

it seems $(".s210").position().top affected margin-top.

why ?

you should set position property relative:

span { position: relative }

javascript jquery

No comments:

Post a Comment