I have a CSS grid that is set to auto-fill
the columns, to display as many items on a row as will fit.
This is done with: grid-template-columns: repeat(auto-fill, minmax(10em, 1fr));
I would like to be able to resize selected grid items, which I am trying with:
resize: both;
overflow: auto;
This works at a basic level, but the content will overlap/stretch over adjacent grid items when resized horizontally:
When resized vertically, the rows below are instead pushed down, so there is no overlap:
This is the behaviour I want horizontally too.
I understand this is likely to do with using auto-fill
for the columns, as when tracks are explicitly defined the stretching works the same on both axes.
.grid {
display: grid;
grid-gap: 1rem;
grid-template-columns: repeat(auto-fill, 10em);
/* grid-template-columns: repeat(auto-fill, minmax(10em, 1fr)); */
}
.grid>div {
background-color: #eeeeff;
padding: 0.5rem;
}
.resize {
resize: both;
overflow: auto;
}
<div class="grid">
<div class="resize">Resize Me</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
</div>