Reputation: 14253
I use this code for fixed header of my page:
jQuery:
$(window).bind('scroll resize', function() {
$('#header').css('top', $(this).scrollTop());
});
CSS:
#header{
position: relative;
}
How can I animate scrollTop()
?
Upvotes: 0
Views: 127
Reputation: 56539
It has to be like
$('#header').scrollTop(value);
atlast
$("#header").animate({ scrollTop: "value in px" })
Upvotes: 0
Reputation: 122026
Try
$('#header').animate({ scrollTop: $(this).scrollTop()}, "slow");
Upvotes: 0
Reputation: 29025
$(window).bind('scroll resize', function() {
var $this = $(this);
$('#header').animate({top : $this.scrollTop()});
});
should work
Upvotes: 1