I have created a simple JSFiddle below. Why is it that my pink box (.screen
) isn't growing to the full height all the way up to the red and blue boxes?
I have tried to set height: 100%
on the screen
div but that makes it grow out-of the the .inner-container
and placing itself above the .bottom
.
EDIT
I have an issue with putting .screen
outside of .inner-container
that I forgot to tell about. When the page is first initialized the .screen
will have a display:none
because the user has not started screen-sharing. When the user clicks the button to share his screen I will set .subscriber
to width: 10rem
and .screen
will be displayed. By just using width I can then "move" the subscriber container from the middle up to the top.
EDIT 2
To more show what I'm after you can remove the flex: 0 1 100%
from .screen
and add width: 100%; height: calc(100% - 10.5rem);
. This just feels like I should be able to do with flex but maybe not.
Solution
I ended up moving the .screen
outside of .inner-container
and I'm dynamically switching the flex-direction between row
and column
on .inner-container
to get the desired outcome. See @vals answer on why this is not possible using flex-box right now.
Here is the JSFiddle: https://jsfiddle.net/kejq01s2/2/
.outer-container {
height: 100vh;
background: yellow;
display: flex;
flex-direction: column;
}
.inner-container {
flex: 1;
display: flex;
flex-wrap: wrap;
}
.publisher {
width: 10rem;
height: 10rem;
background: red;
margin: .5rem;
}
.subscriber {
width: 10rem;
height: 10rem;
background: blue;
margin: .5rem;
}
.screen {
background: pink;
flex: 0 1 100%;
}
.bottom {
width: 100%;
height: 6rem;
background: green;
}
<div class="outer-container">
<div class="inner-container">
<div class="publisher"></div>
<div class="subscriber"></div>
<div class="screen"></div>
</div>
<div class="bottom"></div>
</div>