html中table中td内容换行

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>

扫描二维码关注公众号,回复: 11018796 查看本文章

3.不能设置white-space:nowrap,//连续的空白会被吞并,并且行内换行无效。地址:https://developer.mozilla.org/zh-CN/docs/Web/CSS/white-space

猜你喜欢

转载自www.cnblogs.com/kingsmart/p/12746553.html