更新时间:2023-10-31 23:47:58
这:
$(window).scroll(function () {
var height = $('body').height();
var scrollTop = $(window).scrollTop();
if(scrollTop>500){
$('#header').css({ 'position': 'fixed', 'top' : '0' });
}
else{
$('#header').css({ 'position': 'relative', 'top': '500px'});
}
});