• 全部
  • 问答

如何做到超长字母以及内含PRE的段落自动换行或者出现横向的滚动条啊?

cooler 2006-06-21 12:30:04
我有两段测试代码:
<table border=0 width=400>
<tr>
<td>11
<div sytle="word-break:break-all;word-wrap:break-word;overflow-x:scroll;overflow-y:auto">sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddgggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg</div>
</td>
<td>
</td>
</tr>
</table>

还有一段:
<table border=1 width=400>
<tr>
<td><div style="width:100%;height:100;overflow-x:scroll;overflow-y:scroll">
<br>
<pre>左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格<br>左单元格<br>左单元格<br>左单元格<br>左单元格<br>左单元格<br>左单元格<br>左单元格<br>左单元格<br>左单元格<br>左单元格<br>左单元格<br>左单元格<br>左单元格<br>左单元格<br>左单元格<br>左单元格<br>左单元格<br>左单元格<br>左单元格<br>左单元格<br>左单元格<br>左单元格<br>左单元格<br>
</pre>

</div>

</td>
<td>右单元格
</td>
</tr>
</table>

不管怎么做,都做不到自动换行啊。

我已经尝试了:
1、使用DIV来增加滚动条;
2、使用定长的表格;
3、增加换行的样式;
都不行啊。请教诸位大侠指点了。
...全文
205 点赞 收藏 5
写回复
5 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
HoToo 2006-06-21
可惜是 only ie 的
回复
HoToo 2006-06-21
div中也一样
不过需要控制宽度
回复
春三十一郎 2006-06-21
很多年前传说就一句 td里加入WORD-BREAK: break-all 就可以了
回复
cooler 2006-06-21
回帖有分啊。等待结贴中。
回复
cooler 2006-06-21
等待解决的过程中,发现CSDN居然可以换我发的帖子的行。嘿嘿。就学习了CSDN。发现居然使用textarea实现的。
我也据此改成功的,把成果贴出来共享吧:

<style>
.WithBreaks { word-wrap:break-word;width:580;white-Space:pre;}
.WithBreaks2 { word-wrap:break-word;width:665}
.NormalValue { word-wrap:normal; width:600}
.title0 {font-size:17px;font-family:arial;font-weight:bold;text-decoration:none;color:#FFFFFF;}
A.title2:link {COLOR: #000000; TEXT-DECORATION: none}
A.title2:visited {COLOR: #000000; TEXT-DECORATION: none}
A.title2:active {COLOR: #000000; TEXT-DECORATION: none}
A.title2:hover {COLOR: #000000; TEXT-DECORATION: none}

textarea.content
{
overflow-y:visible;
border:0px;
font-size:12px;
font-family: Tahoma,Verdana,宋体,Fixedsys;
line-height:150%;
overflow:visible;
border-width:0px;
width:550px;
height:40px;
}
</style>

如何做到超长字母以及内含PRE的段落自动换行或者出现横向的滚动条啊?


我有两段测试代码:
<table border=1 width=400>
<tr>
<td>11
<textarea class="content" readOnly rows="1" cols="20">
sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddgggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg
</textarea>
</td>
<td>
</td>
</tr>
</table>

还有一段:
<table border=1 width=400>
<tr>
<td><textarea class="content" readOnly rows="1" cols="20">
<br>
<pre>左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格左单元格<br>左单元格<br>左单元格<br>左单元格<br>左单元格<br>左单元格<br>左单元格<br>左单元格<br>左单元格<br>左单元格<br>左单元格<br>左单元格<br>左单元格<br>左单元格<br>左单元格<br>左单元格<br>左单元格<br>左单元格<br>左单元格<br>左单元格<br>左单元格<br>左单元格<br>左单元格<br>左单元格<br>
</pre>

</textarea>

</td>
<td>右单元格
</td>
</tr>
</table>

回复
发帖
JavaScript
创建于2007-09-28

8.5w+

社区成员

Web 开发 JavaScript
申请成为版主
帖子事件
创建了帖子
2006-06-21 12:30
社区公告
暂无公告