How can I fix the Topbar during scrolling

Hello,

how can I fix the Topbar (not only the navbar) during scrolling on this site:

http://zahn2.riwaro.de

Best regards

Thomas

Hi Thomas,

  • Please add the following code under Customizer > Custom > Global Javascript:
jQuery(function($) {
	$(window).scroll(function(){
        if($(window).scrollTop() > 420 ){
        	$('.x-topbar').addClass('x-topbar-fixed');
        } else {
        	$('.x-topbar').removeClass('x-topbar-fixed');
        }
    });
});
  • Please also add this CSS under Customizer > Custom > Global CSS:
.x-topbar.x-topbar-fixed {
    position: fixed;
    width: 100%;
    top: 0;
}

.x-navbar.x-navbar-fixed-top {
    top: 46px;
}

Let us know how it goes!

1 Like