When using Flexbox, the major mistake is to start using height: 100%
all over.
We are used to that in many cases, though when it comes to Flexbox, it often breaks it instead.
The solution is simple, just remove the height: 100%
, and it will work automatically.
The reason it does, is for flex item in row direction (the default), the align-items
control the vertical behavior, and as its default is stretch
this just work as is.
Stack snippet
<div style='display: flex'>
<div style='background-color: yellow; width: 20px'>
</div>
<div style='background-color: blue'>
some<br> cool<br> text
</div>
</div>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…