前提是div寬度和table寬度固定
代碼:
<style>
div.wid{
width:300px;
white-space:nowrap;
text-overflow:ellipsis;
-o-text-overflow:ellipsis;
overflow: hidden;
}
.tab {
width : 300px;
}
</style>
<div class="wid">this is a very long centence.............................................end</div>
<table border="0" style="table-layout:fixed" class="tab">
<tr>
<td width="100" style="overflow:hidden;text-overflow:ellipsis">this is a very long centence.............................................end
</td>
<td width="100" style="overflow:hidden;text-overflow:ellipsis">this is a very long centence.............................................end
</td>
<td width="100" style="overflow:hidden;text-overflow:ellipsis">this is a very long centence.............................................end
</td>
</tr>
</table>