20

I have some divs with display: table-cell style and I would like to set fixed width on the divs and to truncate the text inside if it doesn't fit.

HTML

<div class="row">
    <div class="cell" style="width:100px;">Should not fit in 100px</div>
</div>

CSS

 .row {
     display: table-row;
}

.cell {
    display: table-cell;
    border: solid 1px #DADADA;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

FIDDLE DEMO

Is it possible?

Levi
  • 657
  • 2
  • 6
  • 14

1 Answers1

16

You can set max-width instead:

<div class="cell" style="max-width:100px;">Should not fit in 100px</div>

fiddle

Alex Char
  • 32,879
  • 9
  • 49
  • 70