I want to achieve the layout of the snippet below:
- non-fixed navbar at the top with unknown height
- fill the remaining screen space with the
#title div - the article continues after the title (not visible on the screen initially, only after scrolling down)
The problem with this snippet is, that it completely breaks the semantic hierarchy of the HTML. The #uglyWrapper splits the article in two parts.
I could use #title { height: calc(100vh - $nav-height) }, but the top bar is a flexbox itself. So $nav-height is unknwon.
Is there a CSS-only solution, that doesn't mess with this HTML structure:
body
nav
article
#title
text
Snippet demonstrating, how it should look like:
#uglyWrapper {
height: 100%;
display: flex;
flex-direction: column;
}
#title {
background-color: lightblue;
height: 100%;
}
html, body {
height: 100%;
margin: 0;
padding: 0;
}
nav {
background-color: grey;
}
<body>
<div id="uglyWrapper">
<nav>top nav with unknown height, not fixed</nav>
<!-- article -->
<div id="title">Full height title image</div>
</div>
Article continues <br>
much text <br>
much text <br>
much text
<!-- /article -->
</body>
Addressing mfluehr's answer:
This approach doesn't fill the remaining space. Instead it fills the entire screen height and gets clipped by the header bar. I left the details about the image intentionally out of the question asking for a div instead. Because there are other elements in that div, that require precise layouting. So covering up an area of unknown size is problematic. Please don't get stuck on the details of the image and use to the minimal example. I can get it working from there.