I have two div's (side by side) inside a parent div, i want right div to occupy 100% of remaining space (i.e. 100% - 200px) and should always stay next to left div (not below left div):
<div id="wrapper" style="width: 100%;">
<div id="left" style="background-color: Blue; height: 100px; float: left; width: 200px;"></div>
<div id="right" style="background-color: Aqua; height: 100px; float: left; width: 100%;"></div>
<div style="clear: both;"></div>
</div>
Add position properties to your right div. Left div 200px and right div occupies remaining space.
Check working example at http://jsfiddle.net/EpA5F/1/
Ok, so on newer browsers we will be able to use display: box; and box-flex: 1,... properties. I am currently using this in a webproject where only Chrome is required, so this new CSS3 thing, solved a lot of issues for me.
If you want right
div
to have constant width:And CSS
Works good without borders
JSFiddle
make the parent wrapper
float
. Also you would probably want to remove thewidth: 100%
in the second child div. And have its width set by the amount of content inside. Or you could have percentage for both child divs. Example30%
and70%
.Demo here
Since you have only one fixed width column, float it left and that is it. As for the second column, do not specify float and width; this makes sure it is 100% wide. But you must add a left margin; otherwise the second column will interfere with the floated column e.g.
your left div should have float left and its pixel width using position relative. Your right div should only have position relative and maybe an overflow hidden. This should fix your problem. No need to use the use the div that clears the float.