I am attempting to nest multiple "blocks" within each other, utilizing flex for this specific case. The structure I am aiming for is as follows:
- Parent (highlighted in blue in JSFIDDLE)
- Container: margin-top: 32px, (highlighted in red)
- Row 1: colored orange (150 px height, width: 100%)
- Row 2: colored violet (with width: 100%, and taking up the remaining height)
- Container: margin-top: 32px, (highlighted in red)
This layout is demonstrated in the code sample provided:
Example 1 on jsfiddle -- issue present
I desire for all embedded divs to either adhere to the specified height (such as 150px for the orange row) or occupy the remaining available height within their parent container. However, the jsfiddle demonstrates that this setup is not functioning as intended: row 2 does not have the required height.
I am aware that it only takes the full height when the parent's height is set to 100%. If I implement this on the container, due to the container's margin-top being set to 32px, both the container and row 2 assume the height of the parent, protruding beyond the parent's bottom boundary. This issue can be observed in this version of the jsfiddle:
Example 2 on jsfiddle -- still not functioning with height:100% on container
How can I resolve this? What would be the correct approach in this scenario?