【发布时间】:2022-08-18 16:39:33
【问题描述】:
.layout {
display: flex;
flex-direction: column;
min-height: 100vh;
}
.body {
flex-grow: 1;
flex-shrink: 0;
background-color: #a0a0a0;
}
.content {
height: 100%;
background-color: #c0c0c0;
}
<div class=\"layout\">
Header
<div class=\"body\">
Body
<div class=\"content\">
Content
</div>
</div>
Footer
</div>
- 为什么
div.content没有占据100% 的窗口? - 有没有办法让
div.content在具有div.layoutflexbox 的同时垂直跨越100%? - 如果没有,我怎样才能在拥有这个 header-body-footer 结构的同时实现它?
编辑 1
-
div.body应遵循默认显示属性。我不能让它成为 flexbox。
-
百分比高度不适用于最小高度。它需要确定的父身高才能起作用。
-
div.body 应该遵循默认的显示属性。我不能让它成为 flexbox。--> 那么你想要的是不可能的
-
最简单的解决方案是在 body 元素上使用
display: grid; grid-auto-rows: auto 1fr;
标签: css