I have some content that I want displayed in the viewport without scrolling. It contains a header, an image and some copy. The copy can be of variable length and must take priority over the image. Flexbox works as intended when flex-direction:row
but when I use flex-direction:column
the image does not respond in the same way - the image and copy bursts out of the container. As the height is changed, I want the image to shrink, with it's container:
HTML:
<div class="container">
<div class="card">
<div class="card-header">
Spanish Omelette
</div>
<div class="image">
<!-- <img src="https://runnerbeantours.com/wp-content/uploads/2020/04/how-to-cook-spanish-omelette.jpg">-->
</div>
<div class="card-content">
<div class="copy">
In order to make a perfect spanish omelette, the potatoes needs to be cut into small slices 2 milimeters thick, then clean the potatoes. You will need a lot of practice!
</div>
</div>
</div>
</div>
SASS:
body {
background:grey;
padding:15px;
}
.container {
display:flex;
justify-content:center;
align-items: stretch;
}
.card {
display:flex;
justify-content:space-between;
flex-direction:column;
width:625px;
background:white;
padding:15px;
border-radius:10px;
height:calc(100vh - 100px);
}
.card-header {
background:orange;
flex:0 1 auto;
}
.card-content {
flex:1 1 auto;
background:yellow;
.copy {
background:yellow;
}
}
.image {
flex:0 2 auto;
background:green;
padding:10px;
img {
width:100%;
height:100%;
}
}
Any ideas?