I'm trying to set up wide flex elements that contain two children (see image at bottom).
The green child element should fill the remaining width of the parent element.
The blue child element should maintain a certain aspect ratio (1 to 0.75, for instance), but ultimately it should fill the height of the parent element.
Here's how I've tried setting this up:
.parent-outer {
display: flex;
flex-direction: row;
height: 250px;
}
.parent-inner {
display: flex;
flex-direction: column;
height: 100%;
}
.blue-child {
height: 100%;
width: 75vh;
background: blue;
}
.green-child {
height: 100%;
flex-grow: 1;
background: green;
}
<div class="parent-outer">
<div class="parent-inner">
<div class="blue-child"></div>
<div class="green-child"></div>
</div>
</div>
This does not seem to be working.
edit: refactor based on Temani Afif's comment -- remove .parent-inner
. Looks like that inner parent div wasn't necessary, but can't seem to get the blue child to fill it's container's height and allow its width to adjust accordingly:
.parent {
display: flex;
flex-direction: row;
height: 250px;
}
.blue-child {
height: 100%;
width: 75vh;
background: blue;
}
.green-child {
height: 100%;
flex-grow: 1;
background: green;
}
<div class="parent">
<div class="blue-child"></div>
<div class="green-child"></div>
</div>