I\'m working on a website that uses two columns inside a container. The container has a white background that should stretch to the bottom of whichever column is highest, so
The easiest fix in this case seems to be adding <br style="clear:both" /> before the closing tag for #container
.
You can change it to <br class="clearfix" />
and .clearfix{clear:both}
if you wish.
Solution is to use inline-block
elements..
Css
.container{
width:300px;
background-color:#ccc;
margin:0 auto;
border:1px solid red;
}
.container > div{
width:150px;
display:inline-block;
vertical-align:top;
}
.inner{
background-color:#666;
margin-top:10px;
width:130px;
}
.left .inner{
margin-left:-10px;
}
.right .inner{
margin-right:-10px;
margin-left:auto;
}
HTML
<div class="container">
<div class="left">
<div class="inner">left 1st inner panel</div>
<div class="inner">left 2nd inner panel</div>
</div><div class="right">
<div class="inner">right 1st inner panel</div>
<div class="inner">right 2nd inner panel with arbitrary text to show the increase in parent elements</div>
</div>
</div>
view demo