Problem: Assume that we have three div elements in a div element as the code below. I want to set the inner div's height auto. For example, if the height of the outer div is 300px and we have three inner elements, the height of the inner element should be 100px.
What I know: If the inner element has no child elements, the height of the inner element is 0px. However, can we change this phenomenon?
Reason: 100px = 300px / 3.
Solver: I can use js to solve this problem. However, I want to know if i can use css to solve this problem.
#outer {
width: 300px;
height: 300px;
;
display: flex;
flex-direction: column;
}
#inner1 {
background: #ccc;
}
#inner2 {
background: red;
}
#inner3 {
background: blue;
}
<div id="outer">
<div id="inner1"></div>
<div id="inner2"></div>
<div id="inner3"></div>
</div>