I have two CSS-Grids. One within the other. I don't want the whole page to scroll, but only the contents of a grid-area of the nested grid. This nested grid should fill all available space. However overflow:scroll does not work within this nested grid.
As you can see in the simplified example below, the div with the class .aside works perfectly while the div with .bottomleft does not scroll at all.
The div-heights start to break with the .main-container - div, but I have no idea why.
What really confuses me is why everything works fine in the .aside - div. The only difference that I can see here is that it is not in the nested grid.
Naturally, everything works perfectly if the .bottom-left - div or the second row of the .main-container - grid are given a fixed height, but the goal is to make it variable.
I also tried adding various max-heights and heights to other parent divs, but was not successful so far.
Thank you!
https://jsfiddle.net/vs6c4gq9/3/
html,
body {
height: 100%;
overflow: hidden;
}
#root {
height: 100%;
}
.container {
display: grid;
grid-template-columns: 1fr 3fr;
grid-template-rows: auto auto;
grid-template-areas: 'nav nav ' 'aside main';
height: 100%;
}
.header {
grid-area: nav;
background-color: lightblue;
}
.main {
grid-area: main;
background-color: lightpink;
height: 100%;
}
.aside {
grid-area: aside;
overflow-y: scroll;
}
.main-container {
display: grid;
grid-template-columns: 1fr 3fr;
grid-template-rows: auto auto;
grid-template-areas: 'topleft topright' 'bottomleft bottomright';
height: 100%;
}
.topleft {
grid-area: topleft;
}
.topright {
grid-area: topright;
}
.bottomleft {
grid-area: bottomleft;
overflow-y: scroll;
height: 100%;
}
.bottomright {
grid-area: bottomright;
}
<div id="root">
<div class="container">
<div class="header">
header
</div>
<div class="main">
<div class="main-container">
<div class="topleft">
topleft
</div>
<div class="topright">
topright
</div>
<div class="bottomleft">
<div>bottomleft</div>
<div>bottomleft</div>
<div>bottomleft</div>
<div>bottomleft</div>
<div>bottomleft</div>
<div>bottomleft</div>
<div>bottomleft</div>
<div>bottomleft</div>
<div>bottomleft</div>
<div>bottomleft</div>
<div>bottomleft</div>
<div>bottomleft</div>
<div>bottomleft</div>
<div>bottomleft</div>
<div>bottomleft</div>
<div>bottomleft</div>
<div>bottomleft</div>
<div>bottomleft</div>
<div>bottomleft</div>
<div>bottomleft</div>
<div>bottomleft</div>
<div>bottomleft</div>
<div>bottomleft</div>
<div>bottomleft</div>
<div>bottomleft</div>
<div>bottomleft</div>
<div>bottomleft</div>
<div>last</div>
</div>
<div class="bottomright">
bottomright
</div>
</div>
</div>
<div class="aside">
<div>aside</div>
<div>aside</div>
<div>aside</div>
<div>aside</div>
<div>aside</div>
<div>aside</div>
<div>aside</div>
<div>aside</div>
<div>aside</div>
<div>aside</div>
<div>aside</div>
<div>aside</div>
<div>aside</div>
<div>aside</div>
<div>aside</div>
<div>aside</div>
<div>aside</div>
<div>aside</div>
<div>aside</div>
<div>aside</div>
<div>aside</div>
<div>aside</div>
<div>aside</div>
<div>aside</div>
<div>aside</div>
<div>aside</div>
<div>aside</div>
<div>aside</div>
<div>aside</div>
<div>aside</div>
<div>aside</div>
<div>aside</div>
<div>aside</div>
<div>aside</div>
<div>aside</div>
<div>aside</div>
<div>last</div>
</div>
</div>
</div>