tabel根据设置的宽度自动换行

CSS: word-break:break-all; word-wrap:break-word;  //此css的作用是根据table设置的宽度来自动换行,如果td里面的内容宽度超出了tabel设置宽度,就会换行

 

Html代码
  1. <table width="200px" border="1" >  
  2.   <tr>  
  3.   <td style="word-break:break-all; word-wrap:break-word;" >序号序号序号序号序号序号序号序号序号序号序号序号序号序号序号序号序号</td>  
  4.   <td style="word-break:break-all; word-wrap:break-word;">dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddD</td>  
  5.   <td style="word-break:break-all; word-wrap:break-word;">111111111111111111111111111111111111111111111111111111111111111111111111111111</td>  
  6.   <td style="word-break:break-all; word-wrap:break-word;">!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!</td>  
  7.   </tr>  
  8. </table>  

2代码

  1. <table width="200px" border="1" style="word-break:break-all; word-wrap:break-word;"  >   
  2.   <tr>   
  3.   <td>序号序号序号序号序号序号序号序号序号序号序号序号序号序号序号序号序号</td>   
  4.   <td>dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddD</td>   
  5.   <td>111111111111111111111111111111111111111111111111111111111111111111111111111111</td>   
  6.   <td>!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!</td>   
  7.   </tr>   
  8. </table>  

你可能感兴趣的:(tabel根据设置的宽度自动换行)