According to css specification on min/max-height, if I don't provide a fixed height for the containing block any percentage min-height
value will be treated as 0
. I have the following example showing that this is either implemented with some quirks or I'm missing something very obvious.
What I want to achieve with this layout
- A 2 column layout with the container having dynamic height depending on the columns height
- The left column should float above the right column
- Both the left and the right column should get the height of the largest column (
align-items: stretch
)
p {
/*Comment out to display more content*/
display: none;
}
.floating-panel-content {
position: relative;
z-index: 1;
background: rgba(0, 100, 0, 0.9);
float: left;
width: 100px;
/*Why does this work? I didn't provide any explicit height.*/
min-height: 100%;
}
.container {
display: flex;
width: 300px;
outline: 1px solid red;
align-items: stretch;
}
.main-panel {
background: blue;
}
img {
display: block;
}
.floating-panel {
flex: 0 0 0;
width: 0;
}
<div class="container">
<div class="floating-panel">
<div class="floating-panel-content">
Floating content
<p>
Lorem ipsum dolor, sit amet consectetur adipisicing elit. Atque maxime aperiam saepe, quia error reiciendis dolorem! Natus facere aliquam sit quisquam, mollitia debitis ullam assumenda atque beatae saepe labore ab.
</p>
</div>
</div>
<div class="main-panel">
<img src="http://placehold.it/300x300">
</div>
</div>
Some content after .container