younglibin 发表于 2013-2-7 23:14:43

<td>……</td>里的字数100,只显示其中20个

如果不是一定要限制字数,可以限制长度的话  
  <table   style="table-layout:fixed;"><tr><td   width=80>  
  <div   style="width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">超级神奇的省略号</div>  
  </td></tr></table>
 
css:
 
 
width: 50%;
 padding-left: 10px;
 
看看效果图:

http://dl.iteye.com/upload/attachment/184087/7235f6da-a6a9-33b9-b8ab-db6c229354b7.png
 
 
 加上一下的CSS代码后:
 overflow:hidden;   隐藏超出范围的数据不显示
 text-overflow:ellipsis;   超出的数据显示为 .......
 white-space:nowrap;    超出的数据不换行
 
看看,这样才好看嘛:

http://dl.iteye.com/upload/attachment/184089/26a0501e-e5a9-3e21-a245-5f75e9cf02b7.png
 
 
多整齐!
 
太强了!多余的就会以........的形式显示出来
 
 
<table>  
  <tr>  
  <td><input   type="hidden"   maxlength="你想要的长度"></td>  
  </tr>  
  </table>  
  把从数据库中提出来内容放到hidden的value中
 
 
页: [1]
查看完整版本: <td>……</td>里的字数100,只显示其中20个