最小高度的父母内部的孩子:100%没有继承身高

最小高度的父母内部的孩子:100%没有继承身高

我找到了一种方法,通过设置使div容器占据页面的至少全高min-height: 100%;。但是,当我添加嵌套的div和set时height: 100%;,它不会延伸到容器的高度。有办法解决吗?


html, body {
  height: 100%;
  margin: 0;}#containment {
  min-height: 100%;
  background: pink;}#containment-shadow-left {
  height: 100%;
  background: aqua;}
<div id="containment">
  <div id="containment-shadow-left">
    Hello World!  </div></div>


蝴蝶刀刀
浏览 521回答 3
3回答

人到中年有点甜

以为我会分享这个,因为我没有在任何地方看到这一点,而且是我用来修复我的解决方案。解决方案:min-height: inherit;我有一个指定最小高度的父母,我需要一个孩子也是那个高度。.parent&nbsp;{ &nbsp;&nbsp;min-height:&nbsp;300px; &nbsp;&nbsp;background-color:&nbsp;rgba(255,255,0,0.5);&nbsp;//yellow}.child&nbsp;{ &nbsp;&nbsp;min-height:&nbsp;inherit; &nbsp;&nbsp;background-color:&nbsp;rgba(0,255,0,0.5);&nbsp;//blue}p&nbsp;{ &nbsp;&nbsp;padding:&nbsp;20px; &nbsp;&nbsp;color:&nbsp;red; &nbsp;&nbsp;font-family:&nbsp;sans-serif; &nbsp;&nbsp;font-weight:&nbsp;bold; &nbsp;&nbsp;text-align:&nbsp;center;}<div&nbsp;class="parent"> &nbsp;&nbsp;<div&nbsp;class="child"> &nbsp;&nbsp;&nbsp;&nbsp;<p>Yellow&nbsp;+&nbsp;Blue&nbsp;=&nbsp;Green&nbsp;:)</p> &nbsp;&nbsp;</div></div>这样,孩子现在充当最小高度的100%的高度。我希望有些人觉得这很有用:)
打开App,查看更多内容
随时随地看视频慕课网APP