The website I'm building has a menu (i.e. navigation bar). The menu shows up on each page. I will have to edit the menu regularly, and so I wanted to have only one menu.html to edit that would be used on all pages, using jQuery's .load
I used this stackoverflow answer to successfully implement my centralized menu. In my index.html it looks like this:
<div id="menu-placeholder">
</div>
<script>
$(function(){
$("#menu-placeholder").load("menu.html");
});
</script>
The menu is a standard .html that has CSS to back it up. They all worked perfectly before centralizing my menu.
However, I want my menu to be sticky, and this no longer works. I have a menu.css which implements a grid and makes it sticky. It worked before I changed to a centralized menu. Now the menu scrolls up without sticking. Elements inside the grid can be made sticky, but they are only sticky in relationship to the menu, not the page. My theory is that because the menu is being loaded into menu-placeholder, the menu is sticky in relation to menu-placeholder, and not in relation to the webpage/body. I have tried to make menu-placeholder sticky, but it doesn't seem to do anything. Is my theory correct? And if so what is the solution? If not, what is causing the problem?