I have three sibling divs in a row:
Right div: A div that has height determined by its text content.
Center div: A div that should match the height of the Right div.
Left div: A div that I want to set at 50% height of the Right div.
CSS attempt using flexbox with Left div not working:
.container {
display: flex;
}
.left {
width: 50px;
height: 50%;
background-color: lightcyan;
}
.center {
width: 50px;
background-color: lightcoral;
}
.right {
width: 300px;
background-color: palegreen;
}
The only way I have discovered to allow the Left div to calculate a percentage of the Right div's height is to use position: absolute
, like in this answer.
Absolute positioning is less than ideal, because it prevents me from using normal layout flow to set the three divs next to each other in a row.
Is there any way I can set the Left div to a percentage of the Right div's height, without needing to use a fixed horizontal layout to set the three divs in a row?
The layout only needs to work in recent Chrome, so browser incompatibilities are not an issue. I am open to solutions using flexbox or table layout.