I'm trying to make a container fill the entire page (or the viewport, whichever is larger), but ran into some trouble. I'm using the recommendations from this post: https://stackoverflow.com/a/17555766, to set the <html>
and <body>
to 100% height.
But I've noticed that the .Content
div only fills the viewport when the <body>
height is set with height: 100%
, but not with min-height: 100%
. Why is that? Why doesn't .Content
pick up the height of the <body>
when it's set with min-height
? Is there a fix for this (without absolute positioning or fixed heights)?
html
<html>
<body>
<div class="Content">Content</div>
</body>
</html>
css
* {
margin: 0;
padding: 0;
}
html {
height: 100%;
}
body {
/* does not work for .Content: */
min-height: 100%;
/* does work for .Content: */
/* height: 100%; */
background: blue;
}
.Content {
background: red;
min-height: 100%;
}
codepen: http://codepen.io/anon/pen/mJEMVX
P.s.: when the <body>
height is set with height: 100%
, both min-height: 100%
and height: 100%
work as expected for .Content
.