<section class="ram">
<div class="block">1</div>
<div class="block">2</div>
<div class="block">3</div>
<div class="block">4</div>
<div class="block">5</div>
<div class="block">6</div>
<div class="block">7</div>
<div class="block">8</div>
<div class="block">9</div>
<div class="block">10</div>
</section>
.ram {
display: grid;
gap: 1em;
grid-template-columns: repeat(auto-fit, minmax(10em, 1fr));
/* Uncomment the line below to prevent blocks from fitting the whole space */
/* grid-template-columns: repeat(auto-fill, minmax(10em, 1fr)); */
}
.block {
display: flex;
justify-content: center;
align-items: center;
color: white;
height: 10em;
background-color: red;
font-size: 1.5rem;
border-radius: 1em;
}
.block:nth-child(2),
.block:nth-child(6) {
background-color: green;
}
.block:nth-child(3),
.block:nth-child(7) {
background-color: blue;
}
.block:nth-child(4),
.block:nth-child(8) {
background-color: black;
}
.block:nth-child(5),
.block:nth-child(10) {
background-color: gold;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.