One unconventional method to achieve this without relying on overflow:hidden is available. However, I believe that overflow:hidden is sufficient on its own. Take a look at the code snippet: http://jsfiddle.net/rj3jecc1/
<div class="container">
<div class="content">Content</div>
<div class="content">Content</div>
<div class="content">Content</div>
</div>
body,html{
height:100%;
margin:0;
padding:0;
}
body{
background:#ddd;
}
.container{
padding-top:1px;
}
.content{
background:#fff;
padding:20px;
margin:20px;
}
An issue arises when setting the body height to 100%, as having a child container with top margin will cause it to extend beyond the 100% height limit, triggering a scrollbar. To counteract this, an additional container with minimal top padding (such as 1px or even 0.1) is introduced to prevent this issue, ensuring functionality across modern browsers.
The necessity of defining the body height as 100% is unclear, and it's advisable to avoid specifying it unless there is certainty that the content will fall short in utilizing the available height (which is uncommon).