A
HTML表应该有多个列。第一列中的信息是最重要的,应该始终可见。其余的列应始终减小其宽度,以便第一列单元格中的文本始终可见。
table {
width: 200px;
max-width: 200px;
table-layout:fixed;
}
td:nth-child(even) {
background-color: #EEE;
}
td {
text-overflow:ellipsis;
overflow: hidden;
white-space: nowrap;
}
<table>
<tr>
<td>Very important text, do not collapse!</td>
<td>aaaa aaaa aaaa aaa aaa aaa</td>
<td>aaaa aaaa aaaa aaa aaa aaa</td></tr>
</table>
这个表平均折叠所有列,这不是我想要的。我尝试禁用第一列的溢出:
table {
width: 200px;
max-width: 200px;
table-layout:fixed;
}
td:nth-child(even) {
background-color: #EEE;
}
td {
text-overflow:ellipsis;
overflow: hidden;
white-space: nowrap;
}
td.no-overflow {
overflow: initial;
}
<table>
<tr>
<td class="no-overflow">Very important text, do not collapse!</td>
<td>aaaa aaaa aaaa aaa aaa aaa</td>
<td>aaaa aaaa aaaa aaa aaa aaa</td></tr>
</table>
不确定是否所有浏览器都显示相同的内容,但在Firefox中,这会在剩余的浏览器上显示第一列,并显示在表外-文本在元素外自由流动。
我也试过:
所以要重申:折叠除第一列以外的所有列,以便适合第一列的文本。不要完全塌陷,保持
min-width: 2em
对于所有列。桌子
如果具有固定宽度,则无法展开以适合列。
我没有主意了。我不想用javascript来做这个。