考虑这个小提琴:http: //jsfiddle.net/BSaWt/1/
<style>
table {
width: 100%;
}
td, th { /* Should be as tight as possible on all resolutions */
width: 5%;
}
.fixedWidth1 { /* Should allways be 90px or smaller */
max-width: 90px;
}
.fixedWidth1 img {
width: 100%;
height: auto;
}
.dynWidth { /* Should allways eat up all remaining width, but be cut if screen width is smaller than table width */
overflow: hidden;
text-overflow: ellipsis;
max-width: 60%
}
.dynWidth > a {
display: block;
}
.dynWidth > span {
display: inline;
}
</style>
<table>
<tr>
<th>col1</th>
<th>col2</th>
<th>col3</th>
<th>col4</th>
<th>col5</th>
<th>col6</th>
</tr>
<tr>
<td class="fixedWidth1">
<a href="#"><img src="category.png" /></a>
</td>
<td class="dynWidth">
<a href="#"><span>A.Way.Too.Large.Text.Which.Cannot.Be.Broken.up.This.ruins.my.entire.layout</span></a>
<span>This column also contains other elements, but they are not a problem. The problem with this column, is that it does not shrink! I want it to cut off text if the space available to the table shrinks.</span>
</td>
<td>Should resize</td>
<td>Should resize</td>
<td>Should resize</td>
<td>Should resize</td>
</tr>
</table>
我知道我可以通过使用 table-layout:fixed 来使表格尊重宽度。但是通过使用它,它将无法正确扩展。我希望桌子能够响应。这是主要问题。另一个事实是,除了前两列之外,所有分辨率的所有 TD、TH 元素都应尽可能紧凑。第一列有一个明确的像素宽度集,第二列应该调整到所有可用的剩余宽度。
这适用于大分辨率,但是当可用宽度减小时,第二列中的文本会阻止表格缩小。
有没有办法让溢出实际上切断文本,以便表格可以缩小到任何大小?