I'm looking to optimize the sorting of two sets of elements with equal amounts. Currently, they appear clustered together. Is there a method to arrange them into a single column, alternating based on their class names? For example, .item1
, .item2
, .item1
, .item2
, and so on.
.item1 {
grid-area: myArea1;
}
.item2 {
grid-area: myArea2;
}
.item1, .item2 {
opacity: 0.2;
}
.grid-container {
display: grid;
grid-template-areas: 'myArea1' 'myArea2';
grid-gap: 10px;
background-color: #2196F3;
padding: 10px;
}
<div class="grid-container">
<div class="item1">1</div>
<div class="item1">11</div>
<div class="item1">111</div>
<div class="item1">1111</div>
<div class="item2">2</div>
<div class="item2">22</div>
<div class="item2">222</div>
<div class="item2">2222</div>
</div>
I'm also interested in non-grid, pure (S)CSS alternatives. The number of items may vary.