I have already been using overflow:auto
but my floats always took as much space as their content was. This caused the columns extend beyond the screen size.
I found the answer in this SO question:
force a div to contain floated child divs
I basically had to make my container contain the floated elements and prevent it from collapsing. http://jsfiddle.net/zfsjb/1/
<style>
#main {
clear: both; /* Contain floating elements */
background-color: red;
}
#main:after { /* Prevents the collapsing of the containing element. */
content: ".";
clear: both; /* */
display: block;
visibility: hidden;
line-height: 0;
height: 0;
}
#primary {
float: left;
margin: 0;
width: 20%;
background-color: yellow;
}
#secondary {
float: left;
width: 80%;
background-color: blue;
}
</style>
<div id="main">
<div id="primary">Primary</div>
<div id="secondary">Secondary</div>
</div>