I have two divs under one parent div, the parent div has 100% width:
<div id="parent">
<div class="left"></div>
<div class="right"></div>
</div>
The conditions are:
- I want two divs on the same line.
- The right div may or may not be present. When it is present, I want it to always be fixed on the right. However, the left div must be elastic – it’s width depends on its content.
I have tried both float:left, and dispaly:inline-block but neither solution seems to work.
Any suggestion would be appreciated.
I’d go with @sandeep’s
display: table-cellanswer if you don’t care about IE7.Otherwise, here’s an alternative, with one downside: the “right”
divhas to come first in the HTML.See: http://jsfiddle.net/thirtydot/qLTMf/
and exactly the same, but with the “right div” removed: http://jsfiddle.net/thirtydot/qLTMf/1/