You have to replace align-content: end;
with align-items: end;
in your grid-container
to able to achieve this.
EDIT :
The align-content
property is used to vertically align the whole grid inside the container. On the other hand grid items
are just boxes inside a grid container which controls the alignment on the block axis. So when align-items
is used we control the position of the item within the grid area. So if you're looking to align only the first div to the top and the remaining to the bottom, using align-items: end;
instead of align-content: end;
is the way to go. Below is an example of it.
Here's more on align-items vs align-content
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
div.grid-container {
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-template-rows: 150px auto; /* added */
grid-gap: 1px;
align-items: end; /* added */
background-color: #059085;
padding: 10px;
color: #000;
/* height: 300px; */ /*removed*/
width: 300px;
}
div.grid-container div.grid-item {
min-width: 100%;
max-height: 25px;
text-align: center;
padding: 5px;
margin: 3px;
border: 2px solid white;
color: white;
}
div.grid-container div:first-child {
align-self: start;
}
<div class="grid-container">
<div class="grid-item" id="first-grid-item">1</div>
<div class="grid-item">2</div>
<div class="grid-item">3</div>
<div class="grid-item">4</div>
</div>