html - 无法在 Chrome 中将 flexbox 子项高度设置为 100%
问题描述
我试图让下面的蓝色框填满按钮的整个高度,但它似乎不起作用。为什么height: 100%
对.el
元素不起作用?
button {
background: red;
height: 55px;
display: flex;
align-items: center;
}
.el {
display: block;
background: blue;
height: 100%;
}
<button>
<span class="el">
Content
</span>
Other
</button>
解决方案
尝试
.el {
display: block;
background: blue;
height: inherit;
}