I have two columns inside a flex container. One of the columns (orange) contains an avatar, and its width should be exactly 10% of the container.
The other column (blue) contains the panel, and the panel title can be very long, so I have to truncate it via css. This figure shows what I expect:
What I expect:
But when I try to do text-overflow: ellipsis
, my second line gets wider than the flex container. Here is an example of this behavior:
https://jsfiddle.net/8krtL9ev/1/
.container { background: #ddd; width: 400px; height: 200px; padding: 10px; display: flex; } .row1 { background: red; flex-basis: 10%; flex-shrink: 0; } .row2 { background: blue; flex-basis: 90%; margin-left: 10px; padding: 10px; display: flex; } .panel { background: green; flex-basis: 50%; overflow: hidden; } .panel-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
<div class="container"> <div class="row1"> </div> <div class="row2"> <div class="panel"> <div class="panel-title"> <span>Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum.</span> </div> </div> </div> </div>
How can I solve this problem?
source share