I essentially want the first block to take up whatever height it will naturally. Then I want the second block fill out the rest of the page with its natural height, without letting it create a vertical scrollbar.
I'm basically hard-coding the 100px via the template row. How can I make things more flexible? I've tried various values like 100%
instead of 100px
in the rows, as well as auto
.
.container {
display: grid;
grid-template-rows: 100px 1fr;
}
.rest {
max-height: calc(100vh - 100px);
}
<div class="container">
<div>
<h1>Welcome</h1>
<h2>Some text that can change length/height</h2>
</div>
<div>
<div class="rest">I want this block to be the remaining 100% height</div>
</div>
</div>