I have a HTML document with following fragment
<main>
<article>A</article>
<article>B</article>
<article>C</article>
<article>D</article>
<article>E</article>
<article>F</article>
<article>G</article>
<article>H</article>
<article>I</article>
<article>J</article>
<aside>Tall content</aside>
</main>
and I would like to put all the articles in left column and strech aside element as sidebar on the right.
I tried following CSS:
main
{
display: grid;
grid-template-columns: 1fr 15rem;
grid-auto-rows: auto auto;
gap: 1rem;
}
article
{
grid-column: 1;
}
aside
{
grid-column: 2;
grid-row: 1 / -1;
}
However, this does not work. The reason is that the -1
in grid-row
refers to end of explicit grid. How to refer to end of implicit or the whole grid?
The list of articles is dynamically generated and I'd prefer not to have to say grid-row: 1 / 11
which would make the example work correctly but requires changing the second number according to content. I'd highly prefer to keep CSS static for all content.