前提是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>
本文详细介绍了如何使用HTML、CSS和JavaScript实现固定宽度的div和table布局,包括文本溢出处理、文本换行及表格布局优化。
132

被折叠的 条评论
为什么被折叠?



