I attempted to merge two different navigation bars, one sticky and the other responsive.
The goal was to combine https://www.w3schools.com/howto/howto_js_navbar_sticky.asp with https://www.w3schools.com/howto/howto_js_responsive_navbar_dropdown.asp
Currently, it seems to be functioning well. Refer to the example below.
function myFunction2() {
var x = document.getElementById("myTopnav");
if (x.className === "topnav") {
x.className += " responsive";
} else {
x.className = "topnav";
}
}
window.onscroll = function() {myFunction()};
var navbar = document.getElementById("navbar");
var sticky = navbar.offsetTop;
function myFunction() {
if (window.pageYOffset >= sticky) {
navbar.classList.add("sticky")
} else {
navbar.classList.remove("sticky");
}
}
...
... [omitted for brevity]
...
However, upon scrolling down with added content making it longer, the dropdown caret appears to not be working on desktop devices.
I tried searching for similar issues on Stack Overflow, but couldn't determine the root cause of this problem.
CSS dropdown with caret
HTML and CSS caret dropdown menu
CSS Dropdown Menu issue
Can someone please provide assistance?
Expected :
https://i.sstatic.net/0K880.png
Problem :