I play with the flexbox system in CSS and I cannot figure out how to solve my problem.
If I have a field with long text that is split into two lines, the window becomes available to the full width, and I do not want this. If the text is on many lines, I want the box to grow to the longest line. Well, my English is not very good, so I have images to better show what I want to achieve.
This is what I have now:

And this is what I want to have:

I was looking for a complete solution in google (and stackoverflow), but with no luck. I also prepared a JSFiddle for this: http://jsfiddle.net/f98VN/4/
Is it possible to do what I want, and if so, how can I achieve this? If not, what are your suggestions?
the code:
HTML
<div class="flex-parent"> <div class="item1"></div> <div class="item2">text is here</div> <div class="item1"></div> </div>
CSS
.flex-parent { display: flex; justify-content: center; width: 550px; align-items: center; } .item1 { background: red; height: 100px; width: 100px; } .item2 { background: pink; font-size: 100px; }
html css flexbox
Rob
source share