我有这样的代码:
<table width="625px">
<tr style="background-color:#CCC; font-size:14px;">
<td style="padding:8px; color:#333"><center><?=stripslashes($arr['signature']);?> </center></td>
</tr>
如果 $arr['signature']
是一个长字符串,像这样 gjuytfdcrtrfdscvythgfvtfdgtrfdvbgfvcfgbdc
宽度没有帮助,它变得非常宽。我怎样才能防止这种情况发生?
最佳答案
方法有很多种,看你想做什么。
如果你申请overflow:hidden
那么溢出的文本将被隐藏。您可以使用 overflow:scroll;
在像 <td style="padding:8px; color:#333"><center><div style="overflow:scroll; width:625px;"><?=stripslashes($arr['signature']);?></div> </center></td>
这样的 div 里面
这将为溢出文本创建一个滚动,仅为该单元格(需要为此方法提供宽度)。
Here overflow:scroll;
的示例
关于HTML 表格宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3602410/