16 April 2013

side by side div with dynamic width


Often we need to build two divs standing side by side, with their width variable (dynamic)



The following code - will help you do it

<div id="container"> 
   <div id="left"> Div 1 - What is my size</div> 
   <div id="right"> Div 2 -I am the <br />Right DIV</div> 
</div>
<style type="text/css"> 
#left {   background: #aaa;   float: left }
#right {   background: cyan;   overflow: hidden } 
#container {   width :400px; } 
</style>

Yours,
Roi