I want to integrate a layout like this one https://jsfiddle.net/przemcio/xLhLuzf9/3/ inside of a larger CSS grid layout. However, it all breaks as soon as a container has the property display: grid
. By "breaks", I mean that the desired flexbox shrinking properties of the .content
div does not apply, and it does not shrink and allow the footer's content to show above the scroll fold.
This is a barebones demo, but in my bigger app there's the same behavior. Why does CSS Grid break this kind of layout, even inside of a child cell, and how can I fix it?
Demo:
html,
body {
height: 100%;
margin: 0
}
.grid {
/* this line breaks it: */
display: grid;
height: 100vh;
}
.cell {
height: 100%;
display: block;
grid-column-end: span 1;
grid-row-end: span 1;
}
.box {
display: flex;
flex-flow: column;
height: 100%;
}
.content {
flex: 1 1 auto;
overflow-y: auto;
border-bottom: 1px solid gray;
}
.footer {
flex: 0 1 auto;
}
<!DOCTYPE html>
<html>
<body>
<div class="grid">
<div class="cell">
<div class="box">
<div class="content">
<p>
<b>content</b> (fills remaining space)
</p>
<p>
<b>content</b> (fills remaining space)
</p>
<p>
<b>content</b> (fills remaining space)
</p>
<p>
<b>content</b> (fills remaining space)
</p>
<p>
<b>content</b> (fills remaining space)
</p>
<p>
<b>content</b> (fills remaining space)
</p>
<p>
<b>content</b> (fills remaining space)
</p>
<p>
<b>content</b> (fills remaining space)
</p>
<p>
<b>content</b> (fills remaining space)
</p>
<p>
<b>content</b> (fills remaining space)
</p>
<p>
<b>content</b> (fills remaining space)
</p>
<p>
<b>content</b> (fills remaining space)
</p>
<p>
<b>content</b> (fills remaining space)
</p>
<p>
<b>content</b> (fills remaining space)
</p>
<p>
<b>content</b> (fills remaining space)
</p>
<p>
<b>content</b> (fills remaining space)
</p>
<p>
<b>content</b> (fills remaining space)
</p>
<p>
<b>content</b> (fills remaining space)
</p>
<p>
<b>content</b> (fills remaining space)
</p>
<p>
<b>content</b> (fills remaining space)
</p>
<p>
<b>content</b> (fills remaining space)
</p>
</div>
<div class="footer">
<p><b>footer</b>
<br>
<br>(sized to content)</p>
</div>
</div>
</div>
</div>
</body>
</html>