我有一个表格,假如宽度是50,表格里一行的字超过了表格的宽度,(默认字体自己会自动换行),我不要字体自己换行,让多出表格宽度的字体自动隐藏,表格里有什么属性可以设置啊?

解决方案 »

  1.   

    <table style="table-layout:fixed;">
      

  2.   

    overflow:hidden试试看,不知道对表格有没效果
      

  3.   

    <html>
    <head>
    <style>
    body{font-size:12px;}
    td{font-size:12px;height:20px; padding:3px; }
    .aa{width:200px; overflow:hidden; text-overflow:clip;}
    .bb{width:200px; overflow:hidden; text-overflow:ellipsis;}
    </style>
    </head>
    <body>
    <table width="500" border="0" cellspacing="1" bgcolor="gray">
      <tr bgcolor="white">
        <td width="200"><div class="aa"><NOBR>超长直接截断超长直接截断超长直接截断超长直接截断超长直接</NOBR></div></td>
        <td width="100" nowrap>产品名称</td>
        <td width="100" nowrap>价格</td>
        <td width="100" nowrap>数量</td>
      </tr>
      <tr bgcolor="white">
        <td width="200"><div class="bb"><NOBR>超长截断并加省略号超长截断并加省略号超长截断并加省</NOBR></div></td>
       <td width="100" nowrap>产品名称</td>
       <td width="100" nowrap>价格</td>
       <td width="100" nowrap>数量</td>
      </tr>
    </table>
    </body>
    </html>关键在于:
    width:xx; overflow:hidden; text-overflow:ellipsis;和<nobr>