欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  web前端

css中文本换行属性word-wrap和white-space

程序员文章站 2022-04-06 10:52:17
...
今天碰到了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>

相关标签: css