Reputation: 324620
My code is very simple:
div {
width: 400px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
#flex {
display: flex;
}
<div id="not-flex">
<span>I am text. I should overflow. When I overflow, I should have an ellipsis at the end.</span>
</div>
<div id="flex">
<span>I am text. I should overflow. When I overflow, I should have an ellipsis at the end.</span>
</div>
Why does flexbox not allow my text-overflow:ellipsis
, and what can I do to make it work?
Upvotes: 4
Views: 1013
Reputation: 1526
You can't put the overflow stuff on the flex box container, you need to put it on the child element.
.box {
display: flex;
width: 300px;
}
.content {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
<div class="box">
<span class="content">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Expedita magnam dolore, ipsam architecto, amet iusto. Doloremque minima inventore eius reiciendis corporis officiis impedit iure vitae voluptates, iste nesciunt, labore natus!</span>
</div>
Upvotes: 1
Reputation: 71150
According to the W3C spec, this is the anticipated behavior, despite the huge number of discussions about it:
This property specifies rendering when inline content overflows its block container element ("the block") in its inline progression direction that has ‘overflow’ other than ‘visible’.
Flex containers are not block containers
Upvotes: 2