jquery如何让div随着滚动条的改变而改变

如题所述

第1个回答  2014-11-05
css中定位设置成position: fixed;就能实现 不需要jqery吧
用jquery的话
window.onscroll=function(){

if($(document).scrollTop()>566){

$("#biandong_right").attr('class',"biandong_right1")

$("#biandong_right_wai").css('position','fixed').css('top','60px')

$('#a1').show()

}

if($(document).scrollTop()<566){

$("#biandong_right").attr('class',"biandong_right")

$("#biandong_right_wai").css('position','')

$('#a1').hide()

}

}
其实也是用jquery改变css本回答被提问者和网友采纳
第2个回答  2014-11-05
那你只要在scroll事件里面改变div的属性就好了

$('html,body').scroll(function(){
    // TODO
})

相似回答