Using the mdbootstrap I have navbar:
<nav class="navbar navbar-expand-lg white">
And it is positioned like this:
While scrolling I add the 'fixed-top' class to the navbar with this script:
let nav = $('.navbar').offset().top;
$(window).bind('scroll', function () {
if ($(window).scrollTop() >= nav) {
$('.navbar').addClass('fixed-top');
} else {
$('.navbar').removeClass('fixed-top');
}
});
This works but: I want to animate the transition between the original and the fixed-top state. I tried with setting a transition time to .navbar{} but it does not work. Do I need to wrap the navbar into another div?