I've come across an example of grid layout and don't understand why adding grid gap to rows and columns causes the row items to overflow the container (which I understand) but not the column items; instead the container expands with no overflow.
body {
padding: 20px;
}
.grid-container {
border: 5px solid black;
font-family: avenir, sans-serif;
font-weight: bold;
display: grid;
grid-template-columns: repeat(4, 25%);
grid-template-rows: 100px 100px;
gap: 20px;
}
.grid-item {
padding: 10px 20px;
}
.grid-item:nth-child(1) {
background: darkcyan;
}
.grid-item:nth-child(2) {
background: turquoise;
}
.grid-item:nth-child(3) {
background: aquamarine;
}
.grid-item:nth-child(4) {
background: lightgreen;
}
.grid-item:nth-child(5) {
background: mediumseagreen;
}
<div class="grid-container">
<div class="grid-item">1</div>
<div class="grid-item">2</div>
<div class="grid-item">3</div>
<div class="grid-item">4</div>
<div class="grid-item">5</div>
</div>