An image can adapt to the width of the parent with this code:
#img-parent {
max-width: 100px;
}
#header-img {
width: 100%;
}
<div id="img-parent">
<img src="https://cdn.pixabay.com/photo/2013/09/16/22/23/yellow-183052_1280.png" id="header-img" alt="">
</div>
But it doesn't care if I set the height of the parent container:
#img-parent {
max-height: 100px;
}
#header-img {
height: 100%;
}
<div id="img-parent">
<img src="https://cdn.pixabay.com/photo/2013/09/16/22/23/yellow-183052_1280.png" id="header-img" alt="">
</div>
Why does this happen, and how can I make the image adapt to the parent's height?