I want the child elements of a height:100%; container to apply height:100%;. This seems to fail when there is a doctype present.
If you use min-height:100%; for the parent, the child elements don't apply height:100%;.
If you use height:100%; the child elements get stretched, but will overflow the parent. If you then try to use height:100%; on the parent and keep min-height:100%; on the children, the children won't stretch anymore.
Here's a little sample:
<!DOCTYPE html>
<html>
<head>
<title>Oh Well</title>
<style>
html, body {
width: 100%;
height:100%;
background: white;
margin:0;
padding:0;
}
#min-h-100 {
background-color: #eee;
min-height: 100%;
}
#min-h-100 > div{
min-height: 100%;
}
#h-100 {
background-color: #ccc;
height: 100%;
}
#h-100 > div {
height: 100%;
}
</style>
</head>
<body>
<div id="min-h-100">
<div>If this is heigher than the container, the container expands.</div>
<div>The child elements do not get 100% height.</div>
</div>
<div id="h-100">
<div>The child elements get 100% height.</div>
<div>But there will be an overflow.</div>
</div>
<div>THIS SHOULD BE PUSHED DOWN</div>
</body>
</html>
edit: min-height doesn't inherit. @GCryrillus came up with the idea to apply display:table to the parent, which at least stretches the parent. @Volker E. created a codepen.
edit: If you don't want to support IE≤8, you can set the child min-height:100vh; which will make it at least as high as the viewport.