admin管理员组文章数量:1356901
My question is, why "text-overflow:ellipsis;" doesnt work for me? I have table on my page and i want to shorten some text inside cell(td). As you can see i have no width parameter in css. I get this value from json and then I set it with jquery. Maybe this is the problem? If so, how can i solve it?
#myTable2 td{
white-space: nowrap;
overflow:hidden;
text-overflow:ellipsis;
min-width:47px;
border-top: solid 1px #ebebeb;
border-spacing:none;
cellpadding: 0;
cellspacing: 0;
font-family:arial;
font-size: 8pt;
color: #3D3D3D;
padding: 4px;
}
I test it in Chrome 19, newest Firefox and IE9.. Thanks
My question is, why "text-overflow:ellipsis;" doesnt work for me? I have table on my page and i want to shorten some text inside cell(td). As you can see i have no width parameter in css. I get this value from json and then I set it with jquery. Maybe this is the problem? If so, how can i solve it?
#myTable2 td{
white-space: nowrap;
overflow:hidden;
text-overflow:ellipsis;
min-width:47px;
border-top: solid 1px #ebebeb;
border-spacing:none;
cellpadding: 0;
cellspacing: 0;
font-family:arial;
font-size: 8pt;
color: #3D3D3D;
padding: 4px;
}
I test it in Chrome 19, newest Firefox and IE9.. Thanks
Share Improve this question edited Jun 20, 2012 at 8:00 Clem asked Jun 20, 2012 at 7:52 ClemClem 11.8k8 gold badges36 silver badges48 bronze badges 3- 1 How do you expect it to shorten the text, when you don't want to place a width limit on it? – lanzz Commented Jun 20, 2012 at 8:03
- yes lanzz this is my question...as i said, i set width from json file...i get there width parameters and then i set it using jaascriopt...width depends on the user... – Clem Commented Jun 20, 2012 at 8:06
- Sorry, misunderstood you. I thought you're setting the text, not the width. – lanzz Commented Jun 20, 2012 at 8:10
2 Answers
Reset to default 5You need a width of the table and table-layout:fixed;
http://jsfiddle/CagPK/
#myTable2 td{
white-space: nowrap;
overflow: hidden;
text-overflow:ellipsis;
}
#myTable2
{
table-layout:fixed;
width: 100px;
}
text-overflow
works with display: block
elements, while table cells are display: table-cell
elements. Enclosing your text in a <div>
should work (fiddle sets the width when you click on the text).
本文标签: javascriptthree dotsoverflowellipsisStack Overflow
版权声明:本文标题:javascript - three dots - overflow:ellipsis - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743949716a2567065.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论