【发布时间】:2015-07-06 00:02:19
【问题描述】:
我有一张桌子
<table class="tbl" border="1">
<tr>
<td width="20%"><span class="spn">column one is a long one</span></td>
<td width="60%"><span class="spn">column two</span></td>
<td width="20%"><span class="spn">column three is the longest of all columns</span></td>
</tr>
</table>
和 CSS 设置:
.spn
{
display: block;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
width: inherit;
color: red;
}
.tbl
{
width: 300px
}
我希望第一列和第三列的宽度为 20%,第二列应为 300px 表格宽度的 60%。文本应填充完整的 td 并以 ... 结尾。如何做到这一点?
【问题讨论】:
-
使用 jquery 或 javascript 怎么样?这样一来,解决起来并不难。或者你想用纯 css 来实现这个?
-
@d_z90 - 仅在可能的情况下使用 css
-
@ChrisSpittles 不是重复的。该用户已经解决了省略号的问题。
标签: html css html-table