Is there an analogue flex-growfor the grid property ?
I would like my grid areas to host the content they receive, but some areas take up more space than others, for example flex-growfor flex.
In practice, in the example below, I would like
turquoise to be invisible because it contains its contents.footer will be invisible since it has no content.- The middle part takes up the rest of the page, for example
flex-grow.
Moreover, I would like to get this code:
.ctnr {
display: grid;
min-height: 100vh;
grid-template-areas:
"header header"
"nav main"
"footer footer";
}
.test {
background: black;
height: 1rem;
}
header {
grid-area: header;
background: turquoise;
}
nav {
grid-area: nav;
background: grey;
}
main {
grid-area: main;
}
footer {
grid-area: footer;
background: yellow
}
<div class="ctnr">
<header>
<div class="test"></div>
</header>
<nav></nav>
<main></main>
<footer></footer>
</div>
Run codeHide resultTo act like this code:
.ctnr {
display: flex;
flex-direction: column;
height: 100vh;
}
.panel {
flex-grow: 1;
display: flex;
}
header {
flex-grow: 0;
background: turquoise;
}
nav {
min-width: 10rem;
background: grey
}
footer {
background: yellow
}
<div class="ctnr">
<header>hey</header>
<div class="panel">
<nav></nav>
<main></main>
</div>
<footer></footer>
</div>
Run codeHide resultWithout div.panel and without adding an additional tag.
, , , div .