I have a div whose height is defined by a flex
display on a enclosing div.
The purpose is to display an image in this div.
My HTML5 code is :
#box {
display: flex;
flex-direction: column;
height: 100vh;
}
#container {
flex: 1 0 auto;
border: 1px solid red ;
}
img {
height:100%;
}
header,footer {
flex: 0 0 20px;
background-color:#aaa;
}
<div id="box">
<header>
this is the header text
</header>
<div id="container">
<img src="http://cimus.eu/editions/(mi)chile/webcimus/hd/001.jpg"/>
</div>
<footer>
this is the footer text
</footer>
</div>
The #container
div as the right size, adapting to window height, but the img exceeds the div height... I would like the img height to fit in the div! I hope I can find a pure CSS3 solution, avoiding JavaScript.
Thanks for any help,
Jean-David