2015-11-03 84 views
5

我的文字换行是不是在所有为什么换行不起作用?

<table border="1" style="width:100%"> 
 
     <thead> 
 
      <tr> 
 
      <th>very long word</th> 
 
      </tr> 
 
     </thead> 
 
     <tbody> 
 
      <tr> 
 
      <td style="word-wrap:break-word;">ablkasd/123123123/agsdfasdf/asdfasdfasdf/_sdfsdfsdf{123123-14werwwer-14124124-wefweshtsdf-235232323}/3235235/dasasdfasdfasdf.bsfs</td> 
 
      </tr> 
 
     </tbody> 
 
    </table>

的字符串不破,总是在同一行工作。

我已经尝试了所有的解决方案从Word Wrap not working properly 但仍然没有工作

回答

8

您将需要添加表:

table {width:100%; table-layout: fixed;} 
 
table td {word-wrap:break-word;}
<table> 
 
    <thead> 
 
     <tr> 
 
     <th>very long word</th> 
 
     </tr> 
 
    </thead> 
 
    <tbody> 
 
     <tr> 
 
     <td>ablkasd/123123123/agsdfasdf/asdfasdfasdf/_sdfsdfsdf{123123-14werwwer-14124124-wefweshtsdf-235232323}/3235235/dasasdfasdfasdf.bsfs</td> 
 
     </tr> 
 
    </tbody> 
 
</table>

+1

本稿请改用直列类方式:) –

+1

@AlexChar我假设OP使用它简单。但是你是对的,单独发布CSS更清晰。 – dfsq