Jurg Verhoeven Jurg Verhoeven - 4 years ago 131
CSS Question

How can I animate a sticky navbar

My project has a sticky header after scrolling that uses this script:

$(document).ready(function() {

$(window).scroll(function () {
//if you hard code, then use console
//.log to determine when you want the
//nav bar to stick.
console.log($(window).scrollTop())
if ($(window).scrollTop() > 385) {
$('#nav').addClass('navbar-fixed');
}
if ($(window).scrollTop() < 386) {
$('#nav').removeClass('navbar-fixed');
}
});
});


How can I animate this so that it looks better?

Answer Source

You can also use jQuery animations. as you are already using jQuery

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download