HTML表中的单词包装我一直在用word-wrap: break-word将文本包装在divS和span然而,它似乎在表单元格中不起作用。我有一张桌子width:100%,有一行和两列。列中的文本,尽管采用上述样式word-wrap不包。它会导致文本超出单元格的界限。这种情况发生在Firefox、GoogleChrome和InternetExplorer上。来源如下:td { border: 1px solid;}<table style="width: 100%;"> <tr> <td> <div style="word-wrap: break-word;"> Looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong word </div> </td> <td><span style="display: inline;">Short word</span></td> </tr></table>上面的长单词比我的页面的边界要大,但它不会与上面的HTML断绝关系。我已经尝试了以下添加的建议text-wrap:suppress和text-wrap:normal但两者都不起作用。
3 回答

红颜莎娜
TA贡献1842条经验 获得超12个赞
以下内容在InternetExplorer中适用于我。注意添加了table-layout:fixedCSS属性
td {
border: 1px solid;
}
<table style="table-layout: fixed; width: 100%">
<tr>
<td style="word-wrap: break-word">
LongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongWord
</td>
</tr>
</table>

波斯汪
TA贡献1811条经验 获得超4个赞
<td style="word-break:break-all;">longtextwithoutspace</td>
<span style="word-break:break-all;">longtextwithoutspace</span>
- 3 回答
- 0 关注
- 326 浏览
相关问题推荐
添加回答
举报
0/150
提交
取消