I need to create header on bottom and make it fixed on top when user scrolling.
Why when I scrolling fixed header is blinking?
It's bit of code:
$(document).scroll(function () {
var bodyTop = $('body').scrollTop();
var navOffset = $('.main-nav').offset().top;
$('.main-nav').toggleClass('header-fixed', (bodyTop > navOffset));
});
.wrapper { height: 99000px; }
.header-fixed {
position: fixed !important; top: 0 !important;
bottom: none; background: yellow !important; }
.main-nav { width: 100%; height: 72px; position: absolute; bottom:0; background: blue;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="wrapper">
<nav class="main-nav">
</nav>
</div>