Is it possible to shrink the middle image (using flex-box) such that when the content in header, footer grows it shrinks such that the total content height of flex children (header, footer, img-wrap) does not overflow out of parent container?
Current view of layout in CodePen
Any help is appreciated. Thanks.
* {
box-sizing: border-box;
}
p,
h4 {
margin: 0;
}
.wrapper {
display: flex;
flex-direction: column;
width: 200px;
height: 200px;
border: 1px solid red;
border-radius: 5px;
}
.wrapper .header,
.wrapper .footer {
flex-grow: 1;
flex-shrink: 0;
}
.header {
background: lightskyblue;
}
.img-wrap {
border: 1px solid black;
flex-grow: 0;
flex-shrink: 3;
min-height: auto;
}
.img-wrap img {
max-width: 100%;
width: 100%;
width: auto;
height: 100%;
height: auto;
vertical-align: bottom;
}
.footer {
border: 1px solid green;
}
.footer .btn {
display: block;
width: 95%;
margin: 0 auto;
padding: 10px;
}
<div class="wrapper">
<div class="header">
<h4>Box title</h4>
<p>Some blurb text Some blurb text Some blurb text Some blurb text </p>
</div>
<div class="img-wrap">
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcShS9EkKjqdM_u5LKC2rI_Utrc0lVvWy5-krg&usqp=CAU" alt="">
</div>
<div class="footer">
<button class="btn">My button</button>
</div>
</div>
