2015-11-03 127 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