I want to use CSS Grid to align the items to stick to all 4 corners of the container box.
How would I do this? Does it make sense to use CSS grid or is it better to use flex box?
I have the following HTML:
<div class="container">
<div class="box1">Box1</div>
<div class="box2">Box2</div>
<div class="box3">Box3</div>
<div class="box4">Box4</div>
</div>
.container {
display: grid;
grid-template-columns: auto auto; /* grid has two columns; content defines width */
justify-content: space-between; /* horizontal alignment of grid tracks */
align-content: space-between; /* vertical alignment of grid tracks */
height: 300px;
background-color: lightgray;
border: 1px solid black;
}
.container > div {
background-color: yellow;
}
<div class="container">
<div class="box1">Box1</div>
<div class="box2">Box2</div>
<div class="box3">Box3</div>
<div class="box4">Box4</div>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With