html - css - 显示 : table-cell and fixed width

标签 html css

<分区>

我有一些 divs 具有 display: table-cell 风格,我想在 divs 上设置固定宽度并截断如果不合适,请在里面添加文字。

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

这可能吗?

最佳答案

您可以改为设置 max-width:

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

fiddle

关于html - css - 显示 : table-cell and fixed width,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25888822/

相关文章:

html - 如何仅将某些规则应用于其文本内容而不是其子项

html - CSS 图像不透明度翻转故障

css - 事件状态不适用于 CSS Sprite

javascript - Jquery - .forEach() 在 IE8 中不工作

javascript - 借助 <tr> 的 id 更改 <td> 内的内容

html - 我怎样才能让我的垂直线完全适合我的 div?

javascript - 使用 OpenLayer3 显示标记、弹出窗口

CSS 将滚动条添加到模态窗口

html - 在 300 像素 x 300 像素表格网格内居中图像

javascript - 编辑在使用 d3js 的 html 中找不到的文本