I'm trying to set up a table via css grid where the first row is a header and remaining rows are just table data.
<div class="grid">
<div class="header">header</div>
<div class="row">a</div>
<div class="row">b</div>
<div class="row">c</div>
<div class="row">d
<div>row with bigger height</div>
</div>
</div>
I'm trying to get the row height to work correctly with the requirements of:
- first row - the header - is
autoheight - every remaining row (2+) is the same height, ie: 1fr based on max-content
- the number of rows is variable, so I can't
repeat()with a fixed number of items (like I have below) - the chart height is dynamic (ie: not a fixed height of, say, 500px)
The closest solution I have is:
.grid {
display: grid;
grid-template-rows: auto repeat(4, minmax(0, 1fr));
}
But I can't do repeat(4) since it needs to be dynamic.
Is this possible to do via css grid, or do I always need to know how many row items exist?
grid-auto-rowsshould cover all rows not explicitly covered bygrid-template-rows, so you can use template rows for the header and auto rows for the others?headerandmainand make them independent from each other? besides that, if it is just a single column then flexbox would be the better choice.