更新时间:2022-10-30 23:01:56
您可以设置 max-width
代替:
< div class =cellstyle =max-width:100px;>不适合100px< / div>
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;
}
Is it possible?
You can set max-width
instead:
<div class="cell" style="max-width:100px;">Should not fit in 100px</div>