亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

FlexBox - 當高度為 100% 時,嵌套 div 不會填充其父級

FlexBox - 當高度為 100% 時,嵌套 div 不會填充其父級

慕妹3146593 2023-09-07 14:30:47
.container {  height: 100vh;  width: 500px;  border: 1px solid black;}.layout {  display: flex;  min-height: 100%;  background-color: blue;  flex-direction: column;}.header {  height: 50px;  background-color: orange;}.main {  flex-grow: 1;  background-color: red;}.main-child {  height: 100%;  width: 100%;  background-color: yellow;}.footer {  justify-self: flex-end;  background-color: purple;}<div class="container">  <div class="layout">    <header class="header">      <input/>    </header>    <main class="main">      <div class="main-child">        <p>          There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable.        </p>        <p>        My Question, why isn't the yellow part the full size of the red part?        </p>      </div>    </main>    <footer class="footer">      <p>        Texty texty text      </p>    </footer>  </div></div>我的嵌套 div 的main-child高度為 100%,但是它不會填充父 div(位于 Flex 盒子內部,并且使用 flex-grow 調整大?。N蚁M蛹墧U展到其父級的填充大小。我該如何解決這個問題?JSFiddle
查看完整描述

1 回答

?
茅侃侃

TA貢獻1842條經驗 獲得超21個贊

.main {

  flex-grow: 1;

  background-color: red;

  display: flex;

}


.main-child {

  flex: 1;

  width: 100%;

  background-color: yellow;

}


查看完整回答
反對 回復 2023-09-07
  • 1 回答
  • 0 關注
  • 91 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號