I am facing an issue with a top sticky navbar on a Bootstrap 4 page. The navbar is set to ease-in/reveal after scrolling down the page, but when it appears, none of the links work, not even changing link colors with :hover. I tried using media queries to hide it initially only on desktop. Here is the code snippet:
@media (max-width: 768px) {
.navbar-home {
opacity: 1!important;
}
}
@media (min-width: 768px) {
.navbar-home {
opacity: 0;
visibility: hidden;
transition: opacity 0.5s ease;
}
}
Javascript:
(function ($) {
$(document).ready(function(){
// scroll functions
$(window).scroll(function(e) {
if($(window).width() >= 768)
var scroll = $(window).scrollTop();
if (scroll >= 150) {
$('.navbar-home').addClass("navbar-hide");
} else {
$('.navbar-home').removeClass("navbar-hide");
}
});
});
})(jQuery);
HTML For Navbar
<nav class="navbar navbar-home navbar-expand-lg navbar-blue fixed-top py-0">
<div class="container">
<a class="navbar-brand" href="index.html"><img src="img/logo.png" alt="" class="logo"/></a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link" href="about.html">About <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="fitness.html">Fitness & Nutrition</a>
</li>
<li class="nav-item">
<a class="nav-link" href="testimonials.html">Testimonials</a>
</li>
<li class="nav-item">
<a class="nav-link" href="blog.html">Blog</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="dropdown" id="dropdown01" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Membership</a>
<div class="dropdown-menu" aria-labelledby="dropdown01">
<a class="dropdown-item" href="membership.html">Memberships</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="https://clients.mindbodyonline.com/ASP/adm/adm_appt_search.asp?studioid=22296&view=&sSU=&qParam=&lvl=&catid=&prodid=&date=12%2F20%2F2018&classid=0&trn=0&tg=&loc=1&vt=&justloggedin=&pMode=0&stype=&page=&prodGroupId=&optForwardingLink=&nLgIn="><i class="fas fa-user"></i> Client Login</a>
</div>
</li>
</ul>
</div>
</div>
</nav>