Are you looking to change the header background based on the user's current site section? If so, you might want to check out the jQuery Waypoints plugin. With this plugin, you can dynamically set classes to elements based on scroll position. Here's the link for more information:
Alternatively, for a CSS-based solution, you can try the codepen provided in the following link:
This method involves using a separate element for the background and adjusting the z-index values to layer the elements properly. For instance, you can have the black background element with a z-index of 1, the image with a z-index of 2, and the navigation with a z-index of 3.
Ensure that the image is set to position:relative;
One thing to note is that you'll need to carefully align the size of the background element with that of the navigation.
For the image:
img {
position:relative;
z-index:999;
}
And for the background element:
.nav-bg {
/* position and height matching the fixed navigation */
position:fixed;
z-index:998;
background:#000;
}