I have a CSS grid with automatic columns and 2 rows, where all but a specific element go into the first row. The special element is placed on the second row, and should fill the whole space used by all columns.
The current implementation is like this:
.TabArea {
display: grid;
grid-auto-columns: auto;
grid-template-rows: auto 1fr;
grid-auto-flow: column;
/* for visualization purposes */
background: gainsboro;
}
.Tab-title {
grid-row: 1;
}
.Tab-body {
grid-row: 2;
grid-column: 1 / -1;
/* for visualization purposes */
background: beige;
}
<div class="TabArea">
<div class="Tab-title">Title A</div>
<div class="Tab-title">Title B</div>
<div class="Tab-title">Title B</div>
<div class="Tab-body">content</div>
</div>
But as you can see, the Tab-body
is only placed on the first column, despite the fact there are additional columns. How can I make it span all columns?
The solution in https://stackoverflow.com/a/44052563/1045510 does not work here because the number of columns is variable, and columns would take up space on the end, pushing the Tab-title
s to the left.