Html - Make Table Width 100% With Last Column Filling Remainder ...
Có thể bạn quan tâm
This is what worked for me (in FireFox, Chrome and old 12.x Opera). My tables which I wanted to have 100% width and the last column to fill the rest has the class tableList and here's CSS:
.tableList { width: 100%; } .tableList td { width: 1px; } /* min width, actually: this causes the width to fit the content */ .tableList td:last-child { width: 100%; } /* well, it's less than 100% in the end, but this still works for me */Below, there's a snippet to try:
.tableList { width: 100%; } .tableList td { width: 1px; } /* min width, actually: this causes the width to fit the content */ .tableList td:last-child { width: 100%; background-color: yellow; } /* well, it's less than 100% in the end, but this still works for me */ <table class="tableList"> <tr><td>game's</td><td>not</td><td>over</td></tr> <tr><td>one</td><td>two</td><td>three and more</td></tr> </table>
Like Rahat has noticed, if the content of a column other than the first one is more than one word, it becomes multiline (one line per word):
.tableList { width: 100%; } .tableList td { width: 1px; } /* min width, actually: this causes the width to fit the content */ .tableList td:last-child { width: 100%; background-color: yellow; } /* well, it's less than 100% in the end, but this still works for me */ <table class="tableList"> <tr><td>game's</td><td>not</td><td>over</td></tr> <tr><td>one</td><td>two plus plus</td><td>three and more</td></tr> </table>
but he also has suggested a workaround – adding white-space: nowrap:
.tableList { width: 100%; } .tableList td { width: 1px; white-space: nowrap; } /* min width, actually: this causes the width to fit the content */ .tableList td:last-child { width: 100%; background-color: yellow; } /* well, it's less than 100% in the end, but this still works for me */ <table class="tableList"> <tr><td>game's</td><td>not</td><td>over</td></tr> <tr><td>one</td><td>two plus plus</td><td>three and more</td></tr> </table>
Từ khóa » Html Table Stretch Last Column
-
Scaling The Last Column In A Table (with Input) To Match The Container
-
HTML Table, First And Last Column Fixed Width And ... - ITecNote
-
Html – Make Table Width 100% With Last Column Filling Remainder ...
-
Nth-last-col - CSS: Cascading Style Sheets - MDN Web Docs
-
Table-layout - CSS: Cascading Style Sheets - MDN Web Docs
-
How To Create A Full Width Table - W3Schools
-
Resize Tables And Cells - Tableau Help
-
How To Fix The Width Of Columns In The Table ? - GeeksforGeeks
-
Make Table Width 100 With Last Column Filling Remainder Without ...
-
How To Set Fixed Width For
In A Table ? - GeeksforGeeks Advanced Table Settings: Column Width, Alignment And Merging Cells
Table-layout - CSS-Tricks
Tables - W3C
Tutorial: Stretching Columns - Handsontable
Copyright © 2022 | Thiết Kế Truyền Hình Cáp Sông Thu