【问题标题】:Overflow not working for div inside a td溢出不适用于 td 内的 div
【发布时间】:2012-10-26 09:39:46
【问题描述】:

所以我试图让溢出属性为 td 内的 div 工作。但是,我以百分比的形式设置 td 的宽度。因此,我无法将 div 的宽度(在 td 内)设置为固定像素数,因为我不会提前知道。

<table id="table">
<thead>
    <tr> 
        <th>column 1</th>
        <th>column 2</th>
    </tr>
</thead>
<tbody>
    <tr>
        <td><div class="cell">Aaaaaaaaaaaaaabbbbbbbbba</div></td>
        <td><div class="cell">bbbbbbbbbbbbbaaaaaaaaaaabb</div></td>
    </tr>
 </tbody>
</table>​


#table {
     width:100px !important;
}

th {
   width:16% !important;
   border: 1px solid black;
}

.cell{
    width:100%;
     overflow: hidden;
    text-overflow: ellipsis;
    -o-text-overflow: ellipsis;
    -webkit-text-overflow: ellipsis;
    white-space: nowrap;
   }

http://jsfiddle.net/2Sync/

有什么想法吗?!

非常感谢!

【问题讨论】:

    标签: javascript jquery css css-tables


    【解决方案1】:

    您可能想尝试添加以下 css 规则:

    #table{
        table-layout:fixed;
        overflow:hidden; 
        white-space: nowrap; 
    }
    

    请在this post 中查看更多信息。

    【讨论】:

      【解决方案2】:

      没关系...我使用了 table-layout:fixed;并且成功了!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-10-08
        • 2014-07-12
        • 1970-01-01
        • 2014-09-17
        • 2019-01-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多