带有自动换行的PRE标签中的问题
对我来说,PRE标签中的自动换行正常,但< TD>保持PRE标签偏离< TD>的指定宽度。或< PRE>。这会影响屏幕的布局。
For me, word wrapping in PRE tag works fine, but the <TD> which holds the PRE tag goes off the specified width of the <TD> or <PRE>. This affects the layout of the screen.
有人可以建议我一个解决方案吗?
Can anyone suggest me a solution?
我的代码如下:
< TABLE> < TR>< TD width =" 300">
<TABLE><TR><TD width="300">
< PRE style =" width:300px;自动换行:break:word">
<PRE style="width:300px;word-wrap:break:word">
冗长的文字到这里!!!冗长的文字在这里!!!冗长的文字在这里!!!冗长的文字在这里!!!冗长的文字在这里!!!冗长的文字在这里!!!冗长的文字在这里!!!冗长的文字在这里!!!冗长的文字在这里!!!冗长的文字在这里!!!冗长的文字在这里!!!
Lengthy text goes here !!! Lengthy text goes here !!!Lengthy text goes here !!!Lengthy text goes here !!! Lengthy text goes here !!! Lengthy text goes here !!!Lengthy text goes here !!!Lengthy text goes here !!!Lengthy text goes here !!!Lengthy text goes here !!!Lengthy text goes here !!!
< / PRE>< / TD>< / TR>< / TABLE>
</PRE></TD></TR></TABLE>
问候
Devi Sri
试试这个:
< 表 样式 =" width:300px; table-layout:fixed; " >
< tr >
< ; td style =" width :100%; ">
< pre style = " 自动换行:break-word ;"> 一些很长的文字phnar phnar < / pre >
< / td >
< / tr >
< / table >
<table style="width: 300px; table-layout: fixed;">
<tr>
<td style="width: 100%;">
<pre style="word-wrap: break-word;">Some quite long text phnar phnar</pre>
</td>
</tr>
</table>
关键是表格布局:固定; - 这将使表格超出您在宽度中指定的范围。自动换行:break-word;会导致预先换行,而不是从桌子的边缘消失。