gpt4 book ai didi

html - 显示 :flex or height:auto not working

转载 作者:太空宇宙 更新时间:2023-11-04 11:22:27 25 4
gpt4 key购买 nike

为什么样式为 display:flex 或 height:auto 的 div 不将 div 扩展到页面底部?特别是当父 div 设置为 height:100% 时?

我提供了一个非常具体的例子来证明这一点:

http://jsfiddle.net/p1fxh128/1/

<div style="height:100vh">
<section style="height:100vh">
Welcome...red div below should fill entire container

<section style="display:flex; flex-direction: column; background:red; height: auto">
<header>
Red Header Here...
</header>
<div>
Red Body here...
</div>
<footer>
Red Footer here...
</footer>
</section>

Random stuff below should still be displayed

</section>
</div>

请注意本例中的红色 div。为什么不垂直填充网格?

最佳答案

我假设您的意思是红色部分应该占用页面的剩余部分而不是页面本身的 100%。

既然如此。

* {
-webkit-background-origin:;
background-origin:;
margin: 0;
}
.wrap {
height:100vh;
}
.wrap > section {
height:100vh;
display:flex;
flex-direction: column;
}
.wrap > section > section {
background:red;
flex:1;
}
<div class="wrap">
<section>Welcome...red div below should fill entire container
<section>
<header>Red Header Here...</header>
<div>Red Body here...</div>
<footer>Red Footer here...</footer>
</section>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sit perferendis fugit, ducimus veniam voluptates debitis. Voluptas, recusandae impedit numquam obcaecati accusamus consequuntur, illo fuga ea enim quod facere, repellat tempore!</section>
</div>

关于html - 显示 :flex or height:auto not working,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32663090/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com