css中文本換行屬性word-wrap和white-space

來源:互聯網
上載者:User
今天碰到了td文字內容不換行,發現是:white-space: nowrap,即強制文本不進行換行,順便看了一下文本換行的屬性word-wrap,總結如下:

white-space的預設只是normal,自動換行。

word-break:break-all和word-wrap:break-word表示強制換行,前者若英文字元過長自動截斷,後者整個英文單詞會換行!

而而我常會這樣用:

word-wrap:break-word; overflow:hidden;

IE 下沒有任何問題,在 FF 下,長串英文會被遮住超出的內容

table中td.th強制換行方法:

<table style="table-layout:fixed" width="200">
<tr>
<td width="25%" style="word-break : break-all; overflow:hidden; ">php點點通(www.phpddt.com)原創教程</td>
<td width="75%" style="word-wrap : break-word; overflow:hidden; ">php點點通(www.phpddt.com)原創教程</td>
</tr>
</table>

  • 相關文章

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.