1.table標簽中添加table-layout:fixed
<table style="table-layout:fixed">
</table>
2.td標簽中樣式添加寬度,width:100px;換行模式:word-break:break-all;//允許在單詞內換行。,word-break:keep-all //只能在半角空格或連字符處換行。
<table style="table-layout:fixed">
<tr>
<td style="width:100px;word-break:keep-all">
要換行的內容
</td>
</tr>
</table>
3.不能設置white-space:nowrap,//連續的空白會被吞並,並且行內換行無效。地址:https://developer.mozilla.org/zh-CN/docs/Web/CSS/white-space