Consider this straightforward example... something that went unnoticed until now.
HTML:
<body>
<div class="container">
<div class="sidebar">
</div>
</div>
</body>
CSS:
*, *:before, *:after {
box-sizing: border-box;
}
html, body, div {
background: rgba(0, 0, 0, .2);
margin: 0;
padding: 20px;
height: 100%;
border: 1px solid #000;
}
.container {
height: 250px;
}
.sidebar {
width: 20%;
}
setting the height of body
to 100% works perfectly in this fiddle.
however, if you expand the size of .container
so it goes beyond the initial window size... you will see the div escaping the boundaries of the body
container (it even seems to break out of the html
container too)?
Reformatted Question
Is there a way to initially set the height of body
to 100% of browser window but at the same time allow the parent containers to adjust accordingly if their children extend beyond the window size?