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

就是,当提供的位置变得窄时能够自动截断需要显示的字符,比如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

 

你可能感兴趣的:(字符串)