css - Strange behavior in jQuery top vs. bottom position -
i'm seeing strange difference between top , bottom positioning. i've put 4 quick examples demonstrate issue:
//example 1 $('#box1').hover(function () { var offset = $('#box1').offset(); $("#containment-wrapper1").css({ bottom: offset.top }); }); //example 2 $('#box2').hover(function () { var x = $('#box2').css('top'); $("#containment-wrapper2").css({ bottom: x }); }); //example 3 $('#box3').hover(function () { var x = $('#box3').css('top'); $("#containment-wrapper3").css({ top: x }); }); //example 4 $('#box4').hover(function () { var offset = $('#box4').offset(); $("#containment-wrapper4").css({ top: offset.top }); });
examples 3 , 4, behave expected, top border lines bottom border.
examples 1 , 2 not. there seems 30px difference.
is bug or missing something?
there no bug , no strange behaviour.
you've set of containers position: fixed
. therefore positioning relative window.
so while distance top never change, distance bottom vary based on screen size. if resize window see position changes , @ point box line up.
the fact measuring distance top , applying bottom makes more fail screen have right size.
basically, asking:
if box is, say, 100px top, why when make containment-wrapper 100px bottom don't line up?
Comments
Post a Comment