0
我有一张表格,其中省略号应该应用于第一个单元格(第一个单元格应该填充剩余空间),但是表格会在父div之外。我怎样才能使它工作?省略号在表格单元格中不起作用
.wrapper {
width:200px;
background: wheat;
}
.el-cell {
width:99%;
display: block;
}
.table {
width: 100%;
}
.no-wrap {
white-space: nowrap;
}
.el {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
<div class="wrapper">
<table class="table">
<tr>
<td class="el-cell">
<div class="el">
<span>first cell should ellipsis aaaaaaa bbbb ccccccc</span>
</div>
</td>
<td>
<span class="no-wrap">2nd cell</span>
</td>
</tr>
</table>
</div>
'表格的布局:fixed' brokes宽度99% - 细胞填充表的一半。 – pwas
为什么不为其他单元格设置1%的宽度?你真的需要在每个单元格内有这么多元素吗?什么是最终目标?请记住,200px的1%太小(2px)。 – Dimcho
因为'99%'使得第一个单元格填充整个可用空间 - 所以第二个单元格不是1% - 它具有其子节点的宽度。 – pwas