使用scrollTop()向下滚动时DIV位置改变; – jQuery

我坚持这一点,希望你们中的任何人都可以帮助我。

我有这个HTML:

 

有了这个CSS:

 #one, #two, #three { width: 100%; height: auto; } 

而这个jQuery:

 $(window).scroll(function(){ var y = $(window).scrollTop(); var one = $('#one').height(); var two = $('#two').scrollTop(); var three = $('#three').scrollTop(); var pos_one = 310; var pos_two = 454; var pos_three = 596; if( y > one ){ $("#header").fadeIn(200); } else { $('#header').fadeOut(200); } if( (y > one) && (y  two) && (y < three) ) { $('.bubble').animate({ "left" : pos_three + "px" }, 300); } }); 

所以,当#到达#two#two正在消失,这是有效的。 我遇到的问题是当滚动时到达其他部分时, .bubble div没有移动。

我究竟做错了什么? 任何帮助将非常感激!

只需使用overflow property

只包括溢出:隐藏在你的CSS之类的东西……

 #one, #two, #three { width: 100%; height: auto; overflow:hidden; } 

您可以根据需要使用房产价值。 这是引用链接溢出属性链接

让我知道它会对你有所帮助???