24

I have a span. I need both the below mentioned styles. But along with display: inline-flex, text-overflow: ellipsis is not working.

.ed-span{
   display: inline-flex!important;
   text-overflow: ellipsis;
 }

when I change inline-flex to inline-block it is working. But I need inline-flex.

How can i make it work?

Please help, Thanks.

Topr
  • 872
  • 3
  • 21
  • 34
Erma
  • 337
  • 1
  • 6
  • 14

3 Answers3

35

I ran into the same issue. What you have to do is put the text within another div which has the overflow style. The inline-flex does not support text-overflow as seen here: https://bugzilla.mozilla.org/show_bug.cgi?id=912434

This should work:

<div class="parent-div">
    <div class="text-div">
    Ellipsis' are cool.
    </div>
</div>

Where the text-div style is as follows:

.text-div {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

And parent-div:

.parent-div {
    display: inline-flex;
}
b.lyte
  • 6,518
  • 4
  • 40
  • 51
0

Just use display: inline-grid in parent-div.

.parent-div {
  display: inline-grid;
  background: cyan;
}

span {
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}
<label class="parent-div">
      <span>
            Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quam, itaque,
            at error rerum ab facere cupiditate veniam incidunt modi temporibus
            explicabo earum minima facilis a excepturi laborum similique
      </span>
</label>
-1

Use min-width: 0 on the display: flex element See full article here: https://css-tricks.com/flexbox-truncated-text/

evanjmg
  • 3,465
  • 1
  • 14
  • 12