I am experimenting with CSS Grid to create a dynamic layout for a small test blog. However, I have encountered an issue related to positioning.
Since the length of the content in the articles is unknown due to it being a blog, using fixed positioning to adjust the layout is not feasible.
Here is my current layout:
https://i.sstatic.net/tVeU5.png
I would like the layout to resemble this:
https://i.sstatic.net/MiWl5.png
My code structure currently looks like this:
CSS
.articles {
margin: 20px;
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-gap: 1em;
}
article {
align-self: start;
}
HTML
<div class="articles">
<article>lorem ipsum...</article>
<article>lorem ipsum...</article>
<article>lorem ipsum...</article>
</div>
The align-self property seems to be functioning correctly by removing the empty space created by the larger (Second) paragraph. However, the third paragraph remains in its original position instead of moving up to fill the now blank space where align-self: stretch
should have worked.
Any suggestions on how to resolve this issue would be greatly appreciated.