I have a table whose width is 80% of screensize. This table contains my menu items. Menu items are in the form of table cells. The design I want is that each cell should only be as wide as the text inside it. But I also want a last cell, that will be empty and be as wide as the remaining space in the table. I.E I want the last to inherit the width of the table (remaining space).
But, all the cells get stretched when I increase table width instead of them just fitting to their text.
How do I stop this from happening?
Thanks!
Extend the last cell to occupy full width:
td:last-child {
width: 100%;
}
…and, if you want to make sure the text in the other cells doesn't collapse:
td {
whitespace: nowrap;
}
Demo here: