I'm trying to place two div's beside each other with the following criteria:
webkit
based browser, so CSS3
solution is preferred.Here are some sample images of how it would look:
Input
<div class='left'>I should always fit. If not, ellipsis should be used.</div><div class='right'>Right align and fit me if space available here.</div>
Output
Input
<div class='left'>I should always fit. If not, ellipsis should be used. And some more text and more, and more text.</div><div class='right'>Right align and fit me if space available here.</div>
Output
Input
<div class='left'>This text is left aligned.</div><div class='right'>This text is right aligned.</div>
Output
I have it with the exception that when there is empty space my right div is eating it (with text right aligned). You don't list that as an ask, so I was unsure if it was just how you drew it? Fiddle here: http://jsfiddle.net/mdares/fSCr6/
HTML:
<div class="container">
<div class="left">Some Text, Repeat, Repeat, Repeat, ,Some Text, and then: </div>
<div class="right">other Text ttt other Text tttother Text tttother Text ttt</div>
</div>
<p />
<div class="container">
<div class="left">Some Text, Repeat, Repeat, Repeat, ,Some Text, Some Text, Repeat, Repeat, Repeat, ,Some Text,</div>
<div class="right">other Text ttt other Text tttother Text tttother Text ttt</div>
</div>
<p />
<div class="container">
<div class="left">Some Text, Repeat, Repeat, Repeat, ,Some Text, </div>
<div class="right">other Text ttt</div>
</div>
CSS:
.container {
width: 600px;
}
.left {
max-width: 100%;
background:red;
white-space:nowrap;
overflow:hidden;
text-overflow:ellipsis;
-ms-text-overflow:ellipsis;
float: left;
}
.right {
background:yellow;
white-space:nowrap;
overflow:hidden;
text-overflow:ellipsis;
-ms-text-overflow:ellipsis;
text-align: right;
}
And finally: