Need to fit img into dynamically calculated height of li due to flex. Currently it takes all height, and pull height content. Image should just fit into dynamically calculated height of LI, e.g. 50px and fit into it.
No hardcoded height is needed. Page should be 100% in any device. header/footer - flex: 1, main - flex: 3.
body,
ul {
margin: 0;
padding: 0;
}
html,
body,
.root {
height: 100%;
}
.root {
display: flex;
flex-direction: column;
}
main {
flex: 3;
background: lightyellow;
}
ul {
display: flex;
flex-direction: column;
height: 100%;
}
ul li {
flex: 1;
background: aliceblue;
outline: 1px solid #000;
display: flex;
/* align-items: center; */
justify-content: space-between;
}
img {
/* object-fit: contain; */
}
header,
footer {
flex: 1;
}
header {
background: lightgray;
}
footer {
background: lightblue;
}
<div class="root">
<header>
HEAD
</header>
<main>
<ul>
<li>
<img src="http://via.placeholder.com/200x200" />
<span>text</span>
</li>
<li>
<img src="http://via.placeholder.com/200x200" />
<span>text</span>
</li>
<li>
<img src="http://via.placeholder.com/200x200" />
<span>text</span>
</li>
</ul>
</main>
<footer>
FOOTER
</footer>
</div>