简体   繁体   English

在Mozilla中的html表中自动换行

[英]Word-wrap in a html table in mozilla

i have a HTML code its working fine in IE but its not working in Mozilla 我有一个HTML代码,它在IE中工作正常,但在Mozilla中不工作

please see code below 请参见下面的代码

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>New Document</TITLE>
</HEAD>

<BODY>
<TABLE BGCOLOR="#B6EBFF" BORDER="3">
 <TR>
  <TD ALIGN="CENTER" STYLE="WORD-BREAK: BREAK-ALL;">
  thisisthetextabcdefghijklthisirrrrrrrrrrrrrrrrrrrsthetextabcdefghijklthisisthetextabcdefghijklthisisthetextabcdefghijklthisisthetextabcdefghijklthisisthetextabcdefghijklthisisthetextabcdefghijklthisisthetextabcdefghijklthisisthetextabcdefghijklthisisthetextabcdefghijklthisisthetextabcdefghijkl

  </TD>
 </TR>
 <TR>
  <TD ALIGN="LEFT" BGCOLOR="FFFEA8">this is the text</TD>
 </TR>
</TABLE>
</BODY>
</HTML>

Please Help 请帮忙

found this somewhere in my bookmarks it still just works with white-spaces. 在我的书签中的某个地方找到了它,它仍然只适用于空格。 Or split the word on a certain character or server-sided. 或在特定字符或服务器端将单词拆分。

td
{
    white-space: pre-wrap; /* css-3 */
    white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
    white-space: -pre-wrap; /* Opera 4-6 */
    white-space: -o-pre-wrap; /* Opera 7 */
    word-wrap: break-word; /* Internet Explorer 5.5+ */
}

Word break and word wrap is for separate words, not for single very long word/sequence of characters. 分词和自动换行适用于单独的单词,而不适用于单个非常长的单词/字符序列。 I hope this rings some bells for you. 我希望这能为您敲响钟声。

If you type "AAAAAAAAAAAAAAAAAAAAAARRRRRRRRRRRRRRRRRRRRRRGGGGGGGGGGGGGGGGGGGGG" this will produce 如果您输入“ AAAAAAAAAAAAAAAAAAAAAAAAARRRRRRRRRRRRRRRRRRRRGRGGGGGGGGGGGGGGGGGGGGGGGGG”,则会产生

AARRRRRRRRRRRRRRRRRRRR
RRGGGGGGGGGGGGGGGGGGGG
G

I have taken my example from a couple different websites on google. 我已经从Google的几个不同网站上借鉴了我的榜样。 I have tested this on ff 5.0, IE 8.0, and Chrome 10. It works on all of them. 我已经在ff 5.0,IE 8.0和Chrome 10上对此进行了测试。它适用于所有这些。

.wrapword{
white-space: -moz-pre-wrap !important;  /* Mozilla, since 1999 */
white-space: -pre-wrap;      /* Opera 4-6 */
white-space: -o-pre-wrap;    /* Opera 7 */
white-space: pre-wrap;       /* css-3 */
word-wrap: break-word;       /* Internet Explorer 5.5+ */
word-break: break-all;
white-space: normal;
}

<table style="table-layout:fixed; width:400px">
    <tr>
        <td class="wrapword">
        </td>
    </tr>
</table>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM