HTML 表格宽度

标签 html css html-table

我有这样的代码:

<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/

相关文章:

CSS 问题 - 背景颜色在 - Magento style.css 中没有响应

html - 如何将按钮和文本输入设置为与表中其他行相同的宽度?

html - html表格显示大量数据的设计思路

javascript - Css 逐像素变换 Y

html - overflow-x 不适用于 td 中包含的内容

javascript - 如何更改此滑动文本区域的位置?

html - 如何停止 Internet Explorer 6/7 显示悬停子菜单

html - 使用flexbox,图像溢出整个容器

CSS/网络套件 : Background Images for Table Row

html - 绝对位置的链接不起作用