【发布时间】:2016-11-15 12:28:34
【问题描述】:
在我的代码中,我试图使file-wrapper div 的内容椭圆化,以便表格的宽度100% 延伸到屏幕宽度。
我根本不知道哪里出错了,因为file-wrapper div 具有指定的像素宽度。
编辑:我现在已将代码简化为基础。
table {
width: 100%;
}
.file-wrapper {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
width: 100%;
}
<table>
<tr>
<td>
<div class="file-wrapper">
testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing
</div>
</td>
</tr>
</table>
【问题讨论】:
-
看起来它正在做你所描述的事情。有什么问题?
-
其他 TD 没有保持它们的宽度。如果您调整浏览器的大小,内容不会一直省略。无论您的浏览器宽度如何,该表格都应 100% 可见。
-
width: calc(100% - 214px) 在你的情况下没有意义,因为它告诉“使 div 100% - 214px 成为单元格的大小”,默认情况下破坏单元格本身 spans为了适合其所有内容,省略号将永远不会显示。在您的情况下,您需要修复 td 的宽度才能使其正常工作。
-
是的,你是对的。
标签: css