My goal in the code snippet below is to make the .content divs fill the height of their parent element (.side-child) by using 100% width and height. The .side-child divs have the correct height, but I am facing an issue with getting the .content images to fill their parent while maintaining aspect ratio.
https://jsfiddle.net/d6L2bve9/5/
<div id="side">
<div class="side-child">
<img src="https://www.icann.org/assets/icann_logo-52672386035a35504af59606040687c8.png" class="content" />
</div>
<div class="side-child">
<img src="https://www.icann.org/assets/icann_logo-52672386035a35504af59606040687c8.png" class="content" />
</div>
<div class="side-child">
<img src="https://www.icann.org/assets/icann_logo-52672386035a35504af59606040687c8.png" class="content" />
</div>
</div>
CSS
#side {
height : 100vh;
display : flex;
flex-direction : column;
width : 50px;
}
.content {
height : 100%;
background : #ff0000;
}
.side-child {
flex-grow : 1;
}
I found a workaround by setting the position of .side-child to relative and .content to absolute as shown below:
https://jsfiddle.net/5sgfcjy4/2/
However, I'm puzzled about why this additional step is necessary since the .side-child divs already have the correct height. Could it be because the .side-child divs do not technically have a specific height value assigned, making it challenging for 100% height to take effect?