今天做项目时碰到个头疼的问题,最后找到解决办法,自己做个备忘!
如果td中字太多,而且不想换行显示的话,可以按照如下进行设置:
<table style="width:100px;height:60px;border:blue solid 1px; table-layout:fixed;">
<tr>
<td align="center" style="overflow:hidden;white-space: nowrap;">
好长啊!好长啊~~~!好长啊!好长啊~~~!好长啊!好长啊~~~!好长啊!好长啊~~~!
</td>
</tr>
</table>
如果想让隐藏的内容用"..."代替的话,按照如下进行设置:
<table style="width:100px;height:60px;border:blue solid 1px; table-layout:fixed;">
<tr>
<td align="center" style="overflow:hidden;white-space: nowrap;text-overflow:ellipsis;">
好长啊!好长啊~~~!好长啊!好长啊~~~!好长啊!好长啊~~~!好长啊!好长啊~~~!
</td>
</tr>
</table>