The below fiddle has three blocks.
block 1 contains three columns. The middle column has two rows within it, each set to flex:1.
block 2 contains three columns. The middle column has two rows within it, each set to flex:1. The second row contains an image of a dog. The image will not shrink to the height of the row within which it is contained.
block 3 contains only the middle column which has two rows within it, each set to flex:1. The second row contains an image of a dog. The image DOES shrink to the height of the row within which it is contained.
The question is why does the image in the second row of the middle column of block 2 not shrink to the height of the row within which it is contained? What CSS rules can I add to make this happen?
.block{
height:100px;
}
.wrapper{
border:5px solid purple;
display:flex;
flex-direction:row;
}
.column{
flex:1;
border:3px solid yellow;
}
.middle{
display:flex;
flex-direction:column;
}
.first{
background:red;
}
.second{
background:orange;
}
.third{
background:purple;
}
.row{
flex:1;
border:1px solid black;
display:flex;
align-items:stretch;
}
img{
flex:1;
}
<div class="wrapper block">
<div class="left column"></div>
<div class="middle column">
<div class="row first"></div>
<div class="row second"></div>
</div>
<div class="right column"></div>
</div>
<div class="wrapper block">
<div class="left column"></div>
<div class="middle column">
<div class="row first"></div>
<div class="row second">
<img src="https://upload.wikimedia.org/wikipedia/commons/8/89/Dog.svg" />
</div>
</div>
<div class="right column"></div>
</div>
<div class="middle block">
<div class="row first"></div>
<div class="row second">
<img src="https://upload.wikimedia.org/wikipedia/commons/8/89/Dog.svg" />
</div>
</div>