jquery inconsistent positioning using offset().top
问题 I am simply trying to position #elementA relative to #elementB. Half the time it ends up with one top value, half the time it gets another, and I can't figure out why. #elementA begins with this CSS: #elementA { display: block; opacity: 0; position: absolute; clear: both; margin-left: -49px; } Then, on $(document).ready(), I set the top value and fade it in. var p = $('#elementB').offset(); $('#elementA').css({ top: p.top - 2 }); $('#elementA').animate({opacity: 1}, 400); Why am I getting