I have a column with 3 rows, all of them with a dynamic height. What I want is to have a the first row with the min-height, the second taking up the free space and the third, with the min-height also.
This, I could achieve, the problem is that I don't want the middle row to push the third row down. So basically, I want the second row to take all the space and have a scroll.
Following my example, the problem occurs when I add a few li elements.
* {
box-sizing: border-box;
}
body {
overflow-y: hidden;
height: 100vh;
}
.grid {
display: grid;
grid-template-rows: min-content 1fr min-content;
height: 100%
}
ul {
list-style: none;
overflow-y: auto;
height: 70%;
}
li {
margin: 5px;
background-color: red;
}
.s-1 {
background-color: green;
min-height: 100px;
}
.s-3 {
background-color: blue;
min-height: 100px;
}
<section class="grid">
<div class="s-1">Section 1</div>
<div>
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
</ul>
</div>
<div class="s-3">Section 3</div>
</section>