I have a css-grid element, and I want to place my grid items by explicitly specifying the column number and row span for each item, while leaving the row number for each item to be sorted out automatically.
.grid-container {
display: grid;
grid-template-columns: 1fr 1fr;
}
.col-1 {
grid-column: 1;
}
.col-2 {
grid-column: 2;
}
.small {
grid-row: span 1;
}
.medium {
grid-row: span 2;
}
.large {
grid-row: span 3;
}
<div class="grid-container">
<div class="col-1 medium">ITEM 1</div>
<div class="col-1 small">ITEM 2</div>
<div class="col-1 medium">ITEM 3</div>
<div class="col-1 small">ITEM 4</div>
<div class="col-1 medium">ITEM 5</div>
<div class="col-1 small">ITEM 6</div>
<div class="col-1 medium">ITEM 7</div>
<div class="col-1 medium">ITEM 8</div>
<div class="col-1 small">ITEM 9</div>
<div class="col-1 large">ITEM 10</div>
<div class="col-1 small">ITEM 11</div>
</div>
I would expect this to place my grid items, starting at the first rows of both columns, yielding a grid consisting of two columns and nine rows. However, right now the first item of the second column is placed in the same row as the last item of the first column, and then new rows are generated for the rest of the items, yielding a grid consisting of two columns and 17 rows.
What do I need to change to achieve the layout I want?