怎样使td中的文本正好适应td的大小?

bbsand 2006-05-10 04:50:51
我有一个表格:
0 1 2 3 4
|aa|bb|cc|dddddd|ee|
| | | |dd | |

td[3]是自动换行的。但是td[4]被隐藏以后,td[3]自动拉长了(因为我设定了Table的宽度)
这时候td[3]仍然是自动换行,但是变成了这样:
3
|dddddd |
|dd |

td还未填满就自动换行了,我希望填满一个td然后自动换行,请问应该设什么属性?或者说应该怎么办才能满足我的要求呢?解决了马上给分!时刻关注!多谢!
...全文
239 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
hchxxzx 2006-05-10
  • 打赏
  • 举报
回复
使用如下方式即可。
<table width="580">
<tr align="left">
<td height="20" width="28" align="center" nowrap>aa</td>
<td height="20" width="78" align="center" nowrap>bb</td>
<td height="20" width="58" align="center" nowrap>cc</td>
<td height="20" width="100%"align="left">ddddddddddddddd</td>
<td height="20" width="78" align="center" nowrap>ee</td>
</tr>
</table>
zeroleonhart 2006-05-10
  • 打赏
  • 举报
回复
用overflow试试看
clare2003 2006-05-10
  • 打赏
  • 举报
回复
<STYLE>
.vis1 { visibility:visible }
.vis2 { visibility:hidden }
</STYLE>
<table width="580">
<tr align="left">
<td height="20" width="28" align="center">aa</td>
<td height="20" width="78" align="center">bb</td>
<td height="20" width="58" align="center">cc</td>
<td height="20" width="58" align="left" style="word-break: break-all;">dddddddddddddddeeeeeee</td>
<td height="20" width="58" onclick="this.className='vis2';">ee</td>
</tr>
</table>
clare2003 2006-05-10
  • 打赏
  • 举报
回复
<STYLE>
.vis1 { visibility:visible }
.vis2 { visibility:hidden }
</STYLE>
<table width="580">
<tr align="left">
<td height="20" width="28" align="center">aa</td>
<td height="20" width="78" align="center">bb</td>
<td height="20" width="58" align="center">cc</td>
<td height="20" width="248"align="left">ddddddddddddddd</td>
<td onclick="this.className='vis2';">ee</td>
</tr>
</table>
laochake 2006-05-10
  • 打赏
  • 举报
回复
<table width=300 border=1>
<tr>
<td>00000</td>
<td>11111</td>
<td>222222222222</td>
<td style="word-break: break-all;">33333333333</td>
<td onclick="this.style.display='none';">44</td>
</tr>
</table>
bbsand 2006-05-10
  • 打赏
  • 举报
回复
<table width="580">
<tr align="left">
<td height="20" width="28" align="center">aa</td>
<td height="20" width="78" align="center">bb</td>
<td height="20" width="58" align="center">cc</td>
<td height="20" width="248"align="left">ddddddddddddddd</td>
<td height="20" width="78" align="center">ee</td>
</tr>
</table>
最后一列需要隐藏。
我试过隐藏后设置第3列的宽度为248+78,不行。。。。
laochake 2006-05-10
  • 打赏
  • 举报
回复
是不是设置了列宽
把代码贴出来看看
bbsand 2006-05-10
  • 打赏
  • 举报
回复
不是这样的,我需要表格撑开,但是想让文字填满撑开后的表格,
不想要它像现在这样,还没添满就换行了,表格后面有空白,
我想要没有空白,都用文字填满。
clare2003 2006-05-10
  • 打赏
  • 举报
回复
用这个css试一下
td,table,tr { word-wrap: break-word; table-layout:fixed;} 这样之后,表格就不会被撑开了

87,904

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧