I am facing an issue with my bootstrap navbar. It seems to be getting stuck when the screen resizes or when viewed on a mobile device. I have tried several solutions from various sources, but none seem to work. Here are some of the answers that I have looked into:
- "Mobile" Bootstrap-Navbar not working
- Bootstrap navbar on mobile not working
image result: [1]: https://drive.google.com/file/d/1uhVIO5o8axQ5EiR08HjpZ8nlZU-RZG3j/view?usp=sharing The problem is that the menu on the right is not opening or closing properly on smaller screens like mobile devices, although it works fine on larger screens.
jQuery(function($) {
$(window).on('scroll', function() {
if ($(this).scrollTop() >= 200) {
$('.navbar').addClass('fixed-top');
} else if ($(this).scrollTop() == 0) {
$('.navbar').removeClass('fixed-top');
}
});
function adjustNav() {
var winWidth = $(window).width(),
dropdown = $('.dropdown'),
dropdownMenu = $('.dropdown-menu');
if (winWidth >= 768) {
dropdown.on('mouseenter', function() {
$(this).addClass('show')
.children(dropdownMenu).addClass('show');
});
dropdown.on('mouseleave', function() {
$(this).removeClass('show')
.children(dropdownMenu).removeClass('show');
});
} else {
dropdown.off('mouseenter mouseleave');
}
}
$(window).on('resize', adjustNav);
adjustNav();
});
@import url('https://fonts.googleapis.com/css?family=Open+Sans:400,700,800');
@import url('https://fonts.googleapis.com/css?family=Lobster');
/* CSS styling code omitted for brevity */