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
A cleaner way would be to simply set a max-width on the td.
Based on @Fabrício Matté's reply,
http://jsfiddle.net/V83Ae/89/
Button 1
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Delectus doloremque magni illo reprehenderit consequuntur quia dicta labore veniam distinctio quod iure vitae porro nesciunt. Minus ipsam facilis! Velit sapiente numquam.
Button 2
And
body { margin: 0; }
.main-table {
width: 100%;
}
.truncate {
text-overflow: ellipsis;
white-space : nowrap;
overflow : hidden;
max-width : 100px; /* Can be any size, just small enough */
}
.nowrap {
white-space: nowrap;
}
I have no idea why this works, but it does, so if someone can figure how why applying a max-width works then please let me know as I did it by accident.
- 热议问题