2015-11-03 21 views
5

My word-wrap không hoạt động ở tất cả cácTại sao từ bọc không hoạt động?

<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>

Chuỗi không phá vỡ và luôn luôn là trong một dòng.

Tôi đã thử tất cả các giải pháp từ Word Wrap not working properly nhưng vẫn không làm việc

Trả lời

8

Bạn sẽ cần phải thêm để bàn:

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

Gợi ý xin vui lòng để sử dụng các lớp học thay vì inline -styles :) –

+1

@AlexChar Tôi giả sử OP đã sử dụng nó để đơn giản. Nhưng bạn là đúng, nó sạch hơn để đăng CSS riêng biệt. – dfsq

Các vấn đề liên quan