$('.b p').height($('.a p').height()); $('.b').scroll(function(){ var t=$('.b').scrollTop(); $('.a p').css('margin-top',-t+'px') })