admin管理员组文章数量:1208155
I'm trying to achieve a responsive list width text-overflow: ellipsis; in the first cell that looks like this:
A one-lined text that is too long and has to be... | Button 2 |
The whole list should have width: 100%; to be as large as the device. I can't set a fixed width on Button 2 since the application is multilingual (a max-width should be possible though).
I can try whatever I want, the ... only appears when I set a fixed width. How can I tell the middle cell to "use the space available" without the help of JavaScript?
Getting Output :
John Doe1 (2) John Doesdfsf...(3) Jo1 (4)
Expected output :
John Doe1(2) John Doesdfsf...(3) Jo1(4)
CSS:
.truncate-ellipsis {
display: inline-block;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
-o-text-overflow: ellipsis;
width: 20%;
}
HTML:
<div ng-app="myApp" ng-controller="validateCtrl">
<ul>
<li><label class="truncate-ellipsis">{{title1}}</label>({{count1}})</li>
<li><label class="truncate-ellipsis">{{title2}}</label>({{count2}})</li>
<li><label class="truncate-ellipsis">{{title3}}</label>({{count3}})</li>
</ul>
</div>
DEMO
I'm trying to achieve a responsive list width text-overflow: ellipsis; in the first cell that looks like this:
A one-lined text that is too long and has to be... | Button 2 |
The whole list should have width: 100%; to be as large as the device. I can't set a fixed width on Button 2 since the application is multilingual (a max-width should be possible though).
I can try whatever I want, the ... only appears when I set a fixed width. How can I tell the middle cell to "use the space available" without the help of JavaScript?
Getting Output :
John Doe1 (2) John Doesdfsf...(3) Jo1 (4)
Expected output :
John Doe1(2) John Doesdfsf...(3) Jo1(4)
CSS:
.truncate-ellipsis {
display: inline-block;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
-o-text-overflow: ellipsis;
width: 20%;
}
HTML:
<div ng-app="myApp" ng-controller="validateCtrl">
<ul>
<li><label class="truncate-ellipsis">{{title1}}</label>({{count1}})</li>
<li><label class="truncate-ellipsis">{{title2}}</label>({{count2}})</li>
<li><label class="truncate-ellipsis">{{title3}}</label>({{count3}})</li>
</ul>
</div>
DEMO
Share Improve this question asked Apr 25, 2016 at 10:07 Gobinath MGobinath M 2,0216 gold badges29 silver badges47 bronze badges1 Answer
Reset to default 18It is working with max-width also:
.truncate-ellipsis {
display: inline-block;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
-o-text-overflow: ellipsis;
max-width: 20%;
}
Example : https://jsfiddle.net/U3pVM/24348/
本文标签: javascriptTruncate ellipsis without widthStack Overflow
版权声明:本文标题:javascript - Truncate ellipsis without width - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738736509a2109592.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论