admin管理员组文章数量:1336633
so I am trying to have the overflow property working for a div inside a td. However, I am setting the width of the td in terms of percentages. Therefore, I can't set the width of the div (inside the td) with a fix number of pixels, since I will not know it in advance.
<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;
}
/
Any ideas?!
Thanks a lot!
so I am trying to have the overflow property working for a div inside a td. However, I am setting the width of the td in terms of percentages. Therefore, I can't set the width of the div (inside the td) with a fix number of pixels, since I will not know it in advance.
<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/2Sync/
Any ideas?!
Thanks a lot!
Share Improve this question asked Oct 26, 2012 at 1:25 abissonabisson 4,42510 gold badges48 silver badges72 bronze badges2 Answers
Reset to default 6You may want to try adding following css rules:
#table{
table-layout:fixed;
overflow:hidden;
white-space: nowrap;
}
Please check more in this post.
Nevermind... I used table-layout:fixed; and it worked!
本文标签: javascriptOverflow not working for div inside a tdStack Overflow
版权声明:本文标题:javascript - Overflow not working for div inside a td - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742398639a2467434.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论