I have a CSS grid layout with a fixed header and footer, and in-between a scrollable content area. See my working prototype: https://codepen.io/tomsoderlund/pen/ZEOzOdX
When implementing this in my live app, I’m struggling to prevent the scrollable area to overflow, without resorting to using height
/max-height
.
See this JSFiddle with the problem: https://jsfiddle.net/tomsoderlund/zfyp76kb/
.messagelist
is the scrollable area. It’s height should be set by its parent .messagelist-and-form
which has grid-template-rows: 1fr auto;
. The header and footer should always be visible, but .messagelist
expands too much.
Update
Even this nested CSS Grid prototype works fine: https://codepen.io/tomsoderlund/pen/xxOKWWP
Update 2: DOM hierarchy explained
body
(absolute, top/bottom: 0).frames
(height: 100%)main
(height: 100%)article.conversation
(height: 100%).messages-and-quote
(height: 100%).messagelist-and-form
(height: 100%).messagelist
(height: 100% adding an absolute height here enables proper scrolling)