为什么在下面的示例中,内部 div
的高度不像包装器的 div
?
HTML:
<div class="wrapper">
<div class="inner">Hello</div>
<div class="inner">Peace</div>
</div>
CSS:
.wrapper {
background-color: #000;
min-height: 100px;
}
.inner {
display: inline-block;
background-color: #777;
height: 100%;
}
如果我将 min-height: 100px;
更改为 height: 100px;
,那么它看起来没问题。但是,就我而言,我需要 min-height
。
原文由 Misha Moroshko 发布,翻译遵循 CC BY-SA 4.0 许可协议
我相信这是你想要的输出:http: //jsfiddle.net/xhp7x/
必须添加第二个 DIV wrapper2。
在 chrome 和 firefox 上测试。