Нет необходимости указывать height:100%
для элемента сетки, так как он создаст неожиданный результат .Затем вы должны скрыть переполнение или включить прокрутку.
html,
body {
height: 100%;
margin: 0
}
.grid {
/* this line breaks it: */
display: grid;
height: 100vh;
}
.cell {
/*height: 100%;*/
overflow:auto;
/*display: block; not needed*/
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>
Вы также можете оставить height:100%
и указать 100vh
в шаблоне строк.В этом случае процентная высота будет вести себя как положено:
html,
body {
height: 100%;
margin: 0
}
.grid {
/* this line breaks it: */
display: grid;
grid-template-rows:100vh;
}
.cell {
height: 100%;
/*display: block; not needed*/
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>