Its a very simple problem but I can't seem to find a suitable solution online. I want to have a list of elements in natural flow with the last element extended to the bottom of the page. So if I have
<div id="top" style="height:50px;"></div>
<div id="bottom" style="background:lightgrey;"></div>
I need element bottom
to extend from the bottom of top
to the bottom of the page. Any solution that uses only html and css is welcome, and you can add container divs or anything, as long as I can get dynamic resizing of the bottom
div
EDIT:
I don't want to hard-code any values for bottom
, because I want bottom
to adjust if top
is resized
here's a fiddle for all your fiddling needs: http://jsfiddle.net/8QnLA/
Set the height of
html, body
to100%
. Then, you can set the last<div>
's height to100%
and it will be as tall as the window. Since you probably don't want scrolling, you can setoverflow: hidden
on thehtml, body
as well.http://jsfiddle.net/GKbzx/
Solution: #1: css tables:
Codepen #1 (little content)
Codepen #2 (lots of content)
Solution #2: Using calc and viewport units
Codepen #1 (little content)
Codepen #2 (lots of content)
Solution #3 - Flexbox
Codepen #1 - little content
Codepen #2 - lots of content