<table border=1 width=100><tr><td>
<div nowrap style="width:100; overflow:hidden">这里就是你想要显示的内容</div></td></tr></table>

解决方案 »

  1.   

    <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="386" height="163" id="AutoNumber1">
        <tr>
          <td width="12" height="52" id= t1> </td>
          <td width="102" height="52"> </td>
          <td width="143" height="52"> </td>
        </tr> 
      </table>
      <input type = button value = sub onclick=sub()><script>
    function sub()
    {  var str= '1111111111112222222222222222222222222222222333333333333333333333334444444444444444444445555555555';
      if  (str.length>5)
      {
        t1.innerText = str.substr(1,5)+'...';
      }
    }
      </script>
      

  2.   

    多谢两位!不过我象要的效果是显示不下时就将后面的用...表示,没有...是不可以的,这样的话界面会不友好。但是我也不知道能够显示的字符个数,所以没有办法采用substr(),且后续补...
    各位帮帮忙,看有什么好方法。
      

  3.   

    有个css方法来着,不过得ie6吧,等我查查
      

  4.   

    "不知道能够显示的字符个数"是什么意思?有length啊。
      

  5.   

    table的style中有个table-layout属性,设置为fixed能满足你的要求。相关属性设置可参考MSDN
      

  6.   

    CSS可以自动在后面加...不过对中文支持极差.还是自己写程序吧.
    <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="386" height="163" id="AutoNumber1">
        <tr>
          <td width="12" height="52" id= t1> </td>
          <td width="102" height="52"> </td>
          <td width="143" height="52"> </td>
        </tr> 
      </table>
      <input type = button value = sub onclick=sub()><script>
    function sub()
    {  var str= '1111111111112222222222222222222222222222222333333333333333333333334444444444444444444445555555555';
      if  (str.length>5)
      {
        t1.innerText = str.substr(1,5)+'...';
      }
    }
      </script>
    ----------------------
    上面程序唯一的不足就是6个英文与6个汉字都会同样处理,但6个英文明显比5个汉字短.
    可以用下面的程序:
    <td width=50 id=t1>111了在工在发厅ABCDD<td>
    <td width=50 id=t2>abc<td>
    <script>function f1()
    {
    iWidth=parseInt(t1.width) while(t1.clientWidth>iWidth)//clientWidth为TD的实际宽度,width为TD定义的宽度,不会跟着TD变宽的
    {
        t1.innerText=t1.innerText.substr(0,t1.innerText.length-4)+"..."
    }}
    </script>
      

  7.   

    找到:text-overflow;和overflow<DIV STYLE="position: absolute; left: 0px; top: 18px; color: black;
                width: 120px; height: 50px; border: 1px solid blue;
                font: 14px Times New Roman, serif; overflow: hidden;
                text-overflow:ellipsis">
    <nobr>在指定列宽asdfasdfsdd的表格中显示字符串,如果一列的宽度不足以显示所有的字符,而客户</nobr>
    </DIV>