I have a table which should be divided into two columns (layout columns, not table columns).
Works fine in all major browsers, except Firefox, which doesn't break the table into two columns.
.column-layout {
columns: 2;
}
<div class="column-layout">
<table>
<tr>
<td>Hello</td>
<td>World</td>
</tr>
<tr>
<td>Hello</td>
<td>World</td>
</tr>
<tr>
<td>Hello</td>
<td>World</td>
</tr>
<tr>
<td>Hello</td>
<td>World</td>
</tr>
<tr>
<td>Hello</td>
<td>World</td>
</tr>
<tr>
<td>Hello</td>
<td>World</td>
</tr>
<tr>
<td>Hello</td>
<td>World</td>
</tr>
<tr>
<td>Hello</td>
<td>World</td>
</tr>
<tr>
<td>Hello</td>
<td>World</td>
</tr>
<tr>
<td>Hello</td>
<td>World</td>
</tr>
<tr>
<td>Hello</td>
<td>World</td>
</tr>
<tr>
<td>Hello</td>
<td>World</td>
</tr>
<tr>
<td>Hello</td>
<td>World</td>
</tr>
<tr>
<td>Hello</td>
<td>World</td>
</tr>
</table>
</div>
You can "run the snippet" in Chrome to see how it should look like. Firefox renders the table in a single row.
The reason for this: There are some long tables, which should be divided into a two column layout in printview.
Is there a workaround to learn Firefox how to break tables into multiple columns?
For firefox, you need also to break the table-layout display but, then it is not a behaving like a table
anymore, columns and rows won't match anymore and noway to use rowspan
nor colspan
.
the easiest is to reset table's element to display:block;
. (think about tbody
which is generated by the browser even when missing within the HTML code).
.column-layout {
columns: 2;
}
/* reset table-layout behavior of HTML table to allow here column-layout but loose the table-layout*/
.column-layout table,
.column-layout tbody,/* don't forget me, i'll be there */
.column-layout tr {
display: block;
}
<div class="column-layout">
<table>
<tr>
<td>Hello</td>
<td>World</td>
</tr>
<tr>
<td>Hello</td>
<td>World</td>
</tr>
<tr>
<td>Hello</td>
<td>World</td>
</tr>
<tr>
<td>Hello</td>
<td>World</td>
</tr>
<tr>
<td>Hello</td>
<td>World</td>
</tr>
<tr>
<td>Hello</td>
<td>World</td>
</tr>
<tr>
<td>Hello</td>
<td>World</td>
</tr>
<tr>
<td>Hello</td>
<td>World</td>
</tr>
<tr>
<td>Hello</td>
<td>World</td>
</tr>
<tr>
<td>Hello</td>
<td>World</td>
</tr>
<tr>
<td>Hello</td>
<td>World</td>
</tr>
<tr>
<td>Hello</td>
<td>World</td>
</tr>
<tr>
<td>Hello</td>
<td>World</td>
</tr>
<tr>
<td>Hello</td>
<td>World</td>
</tr>
</table>
</div>