I tried numerous suggestions but nothing worked so far. The context: I have a centered main section (white background) that stretches nicely to the bottom of the page, using flex. See this image:
Now, there's one section on the website that has lots of content. The issue is that scrolling brings a white background into view while the image should just remain fixed:
I've been able to fix it but that breaks the first view (see below). Here's the HTML and CSS so far (using Bootstrap also).
<body>
<div class="bg flex-column d-flex">
<header class="container">...</header>
<div class="container" flex-grow-1 flex-shrink-0">
<main role="main" class="h-100">
...
</main>
</div>
</div>
</body>
body, html {
height: 100%;
margin: 0;
}
.bg {
background-image: url("../images/bg.jpg");
height: 100%;
background-position: center;
background-repeat: repeat-y;
background-size: cover;
background-attachment: fixed;
}
The "fix"
By changing the css to this:
body, html {
min-height: 100%; /* ! */
margin: 0;
}
the scrolling white background issue is fixed. However, now my other pages are broken because the div doesn't stretch to the page bottom anymore.:
Any help is appreciated.