css - display:table-cell和fixed width

Lev*_*evi 13 html css

我有一些divsdisplay: table-cell风格,我想设置的固定宽度divs,并截断内,如果它不适合文本.

HTML

<div class="row">
    <div class="cell" style="width:100px;">Should not fit in 100px</div>
</div>
Run Code Online (Sandbox Code Playgroud)

CSS

 .row {
     display: table-row;
}

.cell {
    display: table-cell;
    border: solid 1px #DADADA;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
Run Code Online (Sandbox Code Playgroud)

FIDDLE DEMO

可能吗?

Ale*_*har 11

你可以max-width改为:

<div class="cell" style="max-width:100px;">Should not fit in 100px</div>
Run Code Online (Sandbox Code Playgroud)

小提琴