如何强制表格单元格内容换行?

如何强制表格单元格内容换行?,第1张

如何强制表格单元格内容换行?

使用

table-layout:fixed
该表,并
word-wrap:break-word
在TD。

参阅以下示例

<html><head>   <style>   table {border-collapse:collapse; table-layout:fixed; width:310px;}   table td {border:solid 1px #fab; width:100px; word-wrap:break-word;}   </style></head><body>   <table>      <tr>         <td>1</td>         <td>Lorem Ipsum</td>         <td>Lorem Ipsum is simply dummy text of the printing and typesetting industry. </td>      </tr>      <tr>         <td>2</td>         <td>LoremIpsumhasbeentheindustry'sstandarddummytexteversincethe1500s,whenanunknown</td>         <td>Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</td>      </tr>      <tr>         <td>3</td>         <td></td>         <td>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna...</td>      </tr>   </table></body></html>
演示
table {border-collapse:collapse; table-layout:fixed; width:310px;}       table td {border:solid 1px #fab; width:100px; word-wrap:break-word;}       <table>          <tr>  <td>1</td>  <td>Lorem Ipsum</td>  <td>Lorem Ipsum is simply dummy text of the printing and typesetting industry. </td>          </tr>          <tr>  <td>2</td>  <td>LoremIpsumhasbeentheindustry'sstandarddummytexteversincethe1500s,whenanunknown</td>  <td>Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</td>          </tr>          <tr>  <td>3</td>  <td></td>  <td>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna...</td>          </tr>       </table>


欢迎分享,转载请注明来源:内存溢出

原文地址: http://www.outofmemory.cn/zaji/5566954.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-14
下一篇 2022-12-14

发表评论

登录后才能评论

评论列表(0条)

保存