I\'m trying to achieve a responsive table width text-overflow: ellipsis;
in the middle cell that looks like this:
| Button 1 | A one-lined text th
Here you go
<div class="container">
<div>
Button 1
</div>
<div class="fill">
<div class="lockText">
A one-lined text that is too long and has to be...
</div>
</div>
<div>
Button 2
</div>
</div>
The trick is to set up a table layout with a cell that takes up leftover space first (css tables, mind you!).
.container {
display: table;
width: 100%;
}
.container > div {
display: table-cell;
white-space: nowrap;
position : relative;
width : auto;
/*make it easier to see what's going on*/
padding : 2px;
border : 1px solid gray;
}
.container > .fill {
width : 100%;
}
Then add your text that constrains itself within.
.lockText {
position : absolute;
left : 0;
right : 0;
overflow: hidden;
text-overflow: ellipsis;
}