In my code, I am using an outerWrapper
, innerWrapper
, and children. The outerWrapper
has a fixed height of 300px
and is styled with display: flex
. Similarly, the innerWrapper
also has a style of display: flex
with flex-direction: column
.
However, when I apply the align-items
property to the outerWrapper
with anything other than stretch
, the children display in a single long column, disregarding the specified 300px
height. See the image here:
https://i.sstatic.net/X5ieN.png
Instead, I want them to be displayed as shown in this image:
https://i.sstatic.net/osL0x.png
The desired outcome can be achieved by simply applying align-items: flex-end
.
To address this issue, the solution involves setting a height of 210px
for the innerWrapper
. However, this value needs to be dynamically calculated using JavaScript due to the variable number of child elements.
I attempted the following code snippet:
innerWrapper.style.height = (lastChild.offsetTop - innerWrapper.offsetTop + lastChild.offsetHeight) + 'px';
Unfortunately, this did not resolve the issue as it only resulted in a height calculation based on the individual box dimensions.
How can I accurately set the height of innerWrapper
using JavaScript while preserving the flexibility needed for aligning items?