Issue
I have a dynamic footer on my page and I expect the content above it to scale to reach the top of the footer, that's fine and all, but I'm having a problem:
#snippet-container {
height: 300px;
width: 200px;
}
#page {
display: flex;
flex-flow: column;
height: 100%;
}
#content {
flex: 1 1 auto;
background: blue;
}
#content .test {
width: 100%;
height: 100%;
background: yellow;
border: 2px solid red;
}
#footer {
flex: 0 1 10vh;
background: black;
}
<div id="snippet-container">
<div id="page">
<div id="content">
<div class="test"></div>
</div>
<div id="footer"></div>
</div>
</div>
I would expect the .test element to fill the #content element, hence the 100%/100% width/height however it does not.
You can see this reflected as I gave the .test element a red border in the snippet.
Solution
PROBLEM:
The problem is that your #page flex container is not reaching the .test element since .test is not a child, it is a descendant of the flex item.
The contents of a flex container consists of zero or more flex items: each child of a flex container becomes a flex item.
Each flex item is affected by the flex container, but the flex item's descendants are not.
SOLUTION:
You need to add display: flex to your #content as well.
CODE SNIPPET:
#snippet-container {
height: 300px;
width: 200px;
}
#page {
display: flex;
flex-flow: column;
height: 100%;
}
#content {
display: flex;
height: 100%;
background: blue;
}
#content .test {
width: 100%;
background: yellow;
border: 2px solid red;
}
#footer {
flex: 0 1 10vh;
background: black;
}
<div id="snippet-container">
<div id="page">
<div id="content">
<div class="test"></div>
</div>
<div id="footer"></div>
</div>
</div>
Answered By - Ricky
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.