nasdaqhe's blog

被生活强jian着
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

如何根据表格的宽度修改td内字符串长度

Posted on 2006-12-01 15:11  nasdaqhe  阅读(655)  评论(0编辑  收藏  举报

就是,当提供的位置变得窄时能够自动截断需要显示的字符,比如this is a test string.当宽度不够时,就显示this is a ...(或者更少)当宽度够时就全部显示在微软新闻组中看到类似的东西,这里中间的分隔条拖动的时候,左边标题列表的宽度会发生变化,标题文字就自动显示成适合宽度的长度了

 <table border="1" style="table-layout: fixed;">    
    
<tr>      
        
<td width="102" style="overflow: hidden; text-overflow: ellipsis">fdsfdsafdsafdsafdsafdsafdsafdsa</td>      
        
<td width="117" >dddd</td>    
    
</tr>    
    
<tr>      
        
<td >d</td>      
        
<td >d</td>    
    
</tr>  
 
</table>

注意table-layout: fixed  overflow: hidden; text-overflow: ellipsis