给td添加宽度后,发现文字还是超出范围,会根据内容宽度把table撑开,在table 标签添加样式 table-layout: fixed(很关键); 必须设置width的值
:<table style="table-layout: fixed">
<td style="width:50px;">111111111111111111111111</td>
<td style="width:50px;">41322222222222222222222222222222222222</td>
</table>
<style>
table {
width:200px;
border:1px solid green;
}
td {
width:50%;
overflow:hidden;
text-overflow:ellipsis;
white-space:nowrap;
}
</style>