这是想要的样子吗:http: //jsfiddle.net/Uhz8k/?这适用于 Firefox 21+、Chrome 43+(可能更早)和 IE11。它在 IE9 中不起作用。(不知道IE10。)
html代码如下:
<table class="table">
<tr>
<th>First</th>
<th>Second</th>
</tr>
<tr>
<td class="expand-column">
Some long long text here, Some long long text here, Some long long text here,
Some long long text here, Some long long text here, Some long long text here,
Some long long text here, Some long long text here, Some long long text here,
Some long long text here, Some long long text here, Some long long text here.
</td>
<td class="no-wrap"> Other text here </td>
</tr>
<tr>
<td class="expand-column">
Some other long text here, Some other long text here, Some other long text here,
Some other long text here, Some other long text here, Some other long text here,
Some other long text here, Some other long text here, Some other long text here,
Some other long text here, Some other long text here, Some other long text here.
</td>
<td class="no-wrap"> Some other text here </td>
</tr>
</table>
和CSS:
.table {
width: 100%;
border: 1px solid grey;
}
.expand-column {
max-width: 1px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
border: 1px solid grey;
}
.no-wrap {
white-space: nowrap;
border: 1px solid grey;
width: 1px;
}
th {
border: 1px solid grey;
}