I'm making a webpage using Bootstrap starting with a horizontal navbar on the top, followed by a div with a background image and some text over it. This cover is then followed by various containers holding text.
I would like the div with the cover to fill up the remaining space on the window, ie that when you load the page, you only see the navbar followed by the cover, until you scroll (as in http://www.dagconseil.com/, except that my cover does not overlap with the navbar).
So far I either get a cover that is only the size of my text title if I set the position of the corresponding div (.home-cover) to relative:
or an image that covers the whole page until the end, if I use absolute positioning:
which is not what I want either.
Here is the relevant section of the CSS:
html {
position: relative;
min-height: 100%;
}
.navbar {
top: 0;
left: 0;
width: 100%;
}
.home-cover {
position:relative;
height:100%;
min-height:100%;
width:100%;
color: rgb(48,69,151);
}
.home-cover::before {
height:100%;
min-height:100%;
width:100%;
content: "";
background-position:center center;
z-index:0;
-webkit-background-size:cover;
-moz-background-size:cover;
background-size:cover;
-o-background-size: cover;
overflow:hidden;
background-image: url("img/home-cover.jpg");
opacity: 0.4;
top: 0;
left: 0;
bottom: 0;
right: 0;
position: absolute;
}
.home-cover-header {
position: relative;
text-align: center;
width: 100%;
}
And the section of the HTML page:
<nav class="navbar navbar-light navbar-expand-sm flex-nowrap">
<!-- nav bar content -->
</nav>
<div class="home-cover">
<div class="home-cover-header">
<h1>MY AWESOME AGENCY</h1>
<br><br><br><br>
<h2>BRAND CONTENT STRATEGY</h2>
</div>
</div>
<div class="container-large-padding container">
<!-- rest of the content -->
</div>