When you make your navbar sticky in Webflow, it separates from the top hero and turns white because of the default behaviors of the sticky position and the way elements stack in the HTML structure.
The sticky position is a CSS property that allows an element to remain in view regardless of scrolling. In Webflow, when you apply the sticky position to your navbar, it essentially takes it out of the normal flow of the document and creates a new stacking context.
By default, elements with sticky position have a higher z-index value compared to other elements, causing them to stack on top of other non-sticky elements. This behavior is what makes your navbar appear separate from the top hero when you scroll down.
As for the color change to white, it is likely because your layout template sets a specific background color for the navbar. When the navbar becomes sticky, it inherits the default background color from the body or the container it is placed in. If this background color is white, it will cause the navbar to appear white when it becomes fixed.
To address this, you can make a few adjustments. First, you can add a custom class to the navbar element and set a new background color specifically for the sticky state of the navbar. This way, you have more control over the appearance of the sticky navbar.
Additionally, you can set a higher z-index value for the sticky navbar compared to other elements on the page to ensure it remains on top of the content as desired.
To sum up, the navbar separates from the top hero and turns white when it becomes sticky because of the default stacking behavior of sticky elements and the inheritance of background color. By applying custom classes and adjusting z-index values, you can customize the appearance and stacking order of the sticky navbar to suit your design needs.