Solution using CSS2:
HTML
<div class="container">
<div class="left"></div>
<div class="right"></div>
</div>
CSS
.left {
position: absolute;
left: 0px;
right: 100px;
background-color: green;
}
.right {
width: 100px;
background-color: red;
float: right;
}
.left, .right {
height: 50px;
}
.container{
position: relative;
}
Working Fiddle
In the above fiddle, I applied position: absolute
to the .left
container. This makes that container not to stretch the parent element (hence, the layout will break). If you are sure that .left
container's height will be less than the .right
container, then go with the above solution. or else if you know that .left
container's height will be more than the .right
container's height then go with this solution. Fiddle.
If you are unsure of the heights of those containers and you don't want to break the layout, then I think it is better to go with javascript. (no need of javascript, if you know any of the container's height)