I have an issue with CSS grid and an overflowing table. TLDR: When the grid uses fractional units the table won't overflow.
In the example below, the table overflows perfectly.
.table {
overflow-x: auto;
}
<div class="grid">
<div class="navigation">
SideBar
</div>
<div class="content">
<div class="table">
<table>
<tr>
<td>Column 1</td><td>Column 2</td><td>Column 3</td><td>Column 4</td><td>Column 5</td><td>Column 6</td><td>Column 7</td><td>Column 8</td><td>Column 9</td><td>Column 10</td><td>Column 11</td><td>Column 12</td><td>Column 13</td><td>Column 14</td><td>Column 15</td>
</tr>
</table>
</div>
</div>
</div>
However, in the following example the page overflows and not the table:
.table {
overflow-x: auto;
}
.grid {
display: grid;
grid-template-columns: auto 1fr;
}
.navigation {
grid-column: 1;
}
.content {
grid-column: 2;
}
.navigation {
width: 200px;
background: #ccc;
}
<div class="grid">
<div class="navigation">
SideBar
</div>
<div class="content">
<div class="table">
<table>
<tr>
<td>Column 1</td><td>Column 2</td><td>Column 3</td><td>Column 4</td><td>Column 5</td><td>Column 6</td><td>Column 7</td><td>Column 8</td><td>Column 9</td><td>Column 10</td><td>Column 11</td><td>Column 12</td><td>Column 13</td><td>Column 14</td><td>Column 15</td>
</tr>
</table>
</div>
</div>
</div>
I'm stumped. I've tried overflowing the grid element, setting a width, the only thing I have found to work is changing 1fr
to a fixed value which is completely impractical.