So I have the following PageLayout.jsx which I use to set the layout for all of my pages:
export function PageLayout({ children }) {
return (
<div
style={{
height: "100vh",
backgroundImage: "url(" + background + ")",
backgroundSize: "cover",
backgroundAttachment: "fixed",
}}
>
<NavBar />
{children}
<Footer />
</div>
);
}
I want the background to be a fixed image, but to NOT move as the user scrolls (when the page becomes scrollable). In other words, I want only the elements within the page appearing as if they are scrolling.
The image does appear fixed, however, as you scroll, the image is then cut off as it extends past the height of the initial page. I understand this has to do with the fact that my children component overflows the parent div shown in the code. However, I cannot simply set "Overflow: auto", because for whatever reason that causes the browser scroll bar to disappear behind my "fixed: top" navigation bar. Any ideas on what is the proper way of setting a fixed background image?