I am having problems using flexbox properly and wanted to get some clarification on how nesting parent and child elements works.
I know that the child inherits the parent's flex properties, but does that get reverted for any further descendants (e.g. 'grandchildren')? What is the proper usage of flexbox for that?
In other words, do I have to apply display: flex
to the child, too, for the child's children? Will that overwrite the first child's parent's flex properties?
.parent-container {
display: flex;
flex: 1 0 100%;
background-color:yellow;
}
.child-container {
flex: 1 1 50%
background-color: blue;
}
.baby-of-child-container {
flex: 1 1 50%;
background-color: green;
}
<div class='parent-container'>
<div class='child-container'>
<div class='baby-of-child-container'>child</div>
<div class='baby-of-child-container'>child</div>
</div>
<div class='child-container'>
<div class='baby-of-child-container'>child</div>
<div class='baby-of-child-container'>child</div>
</div>
</div>