______________________
| Header |
|______________________|
| |
| |
| Content |
| |
| |
|______________________|
| Footer |
|______________________|
I would like to make this UI, and each is a div. The header height is 30px. And the footer is 30px. But I don’t know the content height. I need to use the user frame to calculate.
The total height should be 100%.
Can I do it in pure CSS?
Using flexbox, this is easy to achieve.
Set the wrapper containing your 3 compartments to
display: flex;and give it a height of100%or100vh. The height of the wrapper will fill the entire height, and thedisplay: flex;will cause all children of this wrapper which has the appropriate flex-properties (for exampleflex:1;) to be controlled with the flexbox-magic.Example markup:
And CSS to accompany it:
Here’s that code live on Codepen: http://codepen.io/enjikaka/pen/zxdYjX/left
You can see more flexbox-magic here: http://philipwalton.github.io/solved-by-flexbox/
Or find a well made documentation here: http://css-tricks.com/snippets/css/a-guide-to-flexbox/
–[Old answer below]–
Here you go: http://jsfiddle.net/pKvxN/
That works on all modern browsers (FF4+, Chrome, Safari, IE8 and IE9+)