Update: This is not the answer. It solves different problem, and it was a step in finding the real answer. So I am keeping it for the historical reasons. Please don't vote on it.
EDIT 2: This answer doesn't solve the problem. There is a subtle difference between target of the question and the answer.
First of all, text-overflow:ellipsis
works with overflow:hidden
. Actually, it works with anything other than overflow:visible
.Ref
Then, iterate through:
http://jsfiddle.net/iamanubhavsaini/QCLjt/8/
Here, I have put overflow
and max-width
properties. max-width:60%;
and overflow:hidden
is what makes things appear as you intended, as hidden
stops the text from displaying and 60%
actually creates the box of definite size in case of too much text data.
Then, if you are really interested in flex box model here's how things pan out via -webkit-order
.
http://jsfiddle.net/iamanubhavsaini/QCLjt/9/
--code--
<div class="container">
<div>foo barfoo bar</div>
<div>foo bar</div>
</div>
<div class="container">
<div>foo barfoo barfoo barfoo barfoo barfoo barfoo bar
foo barfoo barfoo barfoo barfoo barfoo barfoo bar
foo barfoo barfoo barfoo barfoo barfoo barfoo bar</div>
<div>foo bar</div>
</div>
concerned CSS
.container {
display: -webkit-flex;
}
div {
white-space: nowrap;
text-overflow: ellipsis;
overflow:hidden;
}
.container>div:first-child{
-webkit-order:1;
-webkit-flex: 1;
}
.container > div:last-child {
-webkit-flex: 1;
-webkit-order:2;
background: red;
}
--
There is no width and still it works. And this is what I see.

--after comment
-webkit-order:N; is the what we will be using after 2+ years instead of float:---;
and many more hacks(if W3C stays on this course and also if every browser vendor follow)
here, order is 1 for the left div and 2 for the right div. thus, they are Left-Right.
http://jsfiddle.net/iamanubhavsaini/QCLjt/10/
same thing here, but only if you are looking for Right-Left, just change the order of the things as div>first-child { -webkit-order:2; } div>last-child{-webkit-order:1;}
NOTE: this -webkit-flex
way of doing things obviously renders this code useless on other engines. For, reuse of code, on multiple browser engines float
ing should be used.
below are some JS examples; that doesn't answer the question -after comment
I think this answers your question and many more to come, there are some other ways and different solutions but not exactly the solution for this question.
http://jsfiddle.net/iamanubhavsaini/vtaY8/1/
http://jsfiddle.net/iamanubhavsaini/9z3Qr/3/
http://jsfiddle.net/iamanubhavsaini/33v8g/4/
http://jsfiddle.net/iamanubhavsaini/33v8g/1/