Imagine we have two CSS grid containers with a dynamic columns count based on width:
display: grid;
grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
The grid works perfectly, but what if we need to have another grid to have the first column to be same as in another grid with the code shown above, but it's another column to span through more cells - depending on how many cells are in the current row?
To better understand the issue, there are images:
On a narrower wrapper:
We would need to apply something like grid-column: span ALL
(if something like that exists), with meaning that ALL = till the end of the current row.
It is really important that "First" column should always align with the "1" column.
The code to run the example is here:
.grid div {
/* Not important fancy styles */
height: 40px;
text-align: center;
padding-top: 20px;
}
.grid {
width: 350px;
display: grid;
grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
background-color: silver;
}
.grid-second {
background-color: red;
}
.grid-another {
background-color: purple;
border: 1px solid gray;
}
<div class="grid">
<div class="grid-first">
First
</div>
<div class="grid-second">
Second (Want till end)
</div>
</div>
<!-- Another same grid -->
<div class="grid">
<div class="grid-another">
1
</div>
<div class="grid-another">
2
</div>
<div class="grid-another">
3
</div>
<div class="grid-another">
4
</div>
</div>
PS: Please do not post solutions using a media query. I am interested in any (even a little hacky) solution, which will work without usage of media queries.