I made a menu that perceives when the scroll
passes from a certain point and stays fixed, until all right, but when I rolled the page a little lower, and updated (F5) I noticed that the menu disappeared, and then scrolling once up / down scrolls it back up.
Does anyone know what I could do for this not to occur, pop up the tbm menu when giving a refresh / f5?
Follow the code below.
$(document).ready(function(){
var div = $('#menu');
$(window).scroll(function () {
if ($(this).scrollTop() > 35) {
div.addClass("menu-fixo");
} else {
div.removeClass("menu-fixo");
}
});
});
#menu {
min-height: 112px;
background-color: tomato;
}
.menu-fixo {
position: fixed;
top: 0px;
left: 0;
right: 0;
z-index: 100;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><divid="menusite" class="container-fluid">
<div class="row">
<div class="col-md-12"> Menu </div>
</div>
<div>