I am trying to create a table that adheres to the following requirements:
- The width of the table should be defined as 0 - the browser should calculate the width according to the width of the column (this should be provided for the plugin with the column size).
- Some columns may take a fixed width (e.g. 50px);
- Columns that do not get a fixed width should automatically match the content.
I created a small example to illustrate the problem - since you can see that column 3 remains at width 0 and therefore is not displayed.
EDIT . If "table-layout: fixed" is deleted. a third column appears, but fixed widths are ignored, and all columns become auto-adjustable.
HTML
<table> <tr> <td class="cell header" id="header1">Header 1</td> <td class="cell header" id="header2">Header 2</td> <td class="cell header" id="header3">Header 3</td> </tr> <tr> <td class="cell">Cell 1</td> <td class="cell">Cell 2</td> <td class="cell">Very looooong content</td> </tr> </table>
CSS
table { table-layout: fixed; width: 100%; border: 1px solid #696969; } .cell { color: #898989; border: 1px solid #888; padding: 2px; overflow: hidden; } .header { background-color: lightsteelblue; color: black; } #header1, #header2 { width: 50px; }
Is it possible? Any help would be appreciated ...
source share