【发布时间】:2019-05-27 20:32:37
【问题描述】:
为什么将height:100% 设置为具有flex-grow:1 的弹性项目(也是弹性容器)的子项不能按预期工作?
将height: 100% 设置为此子元素应该使其具有其父元素(flex-grow:1 父元素)的高度,但事实并非如此,所以我显然错了。
我想知道height:100% 在这种情况下的含义。为什么使用此设置项目不占据其父项的全部高度。
这是 HTML(需要引导)
.theHeader {
background-color: #336B87;
color: white;
padding: 5px 15px;
}
.project-manager {
border-right: 1px solid black;
height: 100%;
}
.flex-content {
display: flex;
flex-flow: column;
height: 100vh;
}
.flex-grow-this {
flex-grow: 1;
}
<div class="container-fluid flex-content">
<header class="container-fluid theHeader">
<h1 class="logo">ToDo Manager</h1>
</header>
<div class="container-fluid row flex-grow-this">
<aside class="col-2 project-manager">
sek
</aside>
<section class="col-10 to-do-list">
</section>
</div>
</div><!--end of main div-->
【问题讨论】:
-
它已经占用了其父级的 100%(带有类
container-fluid row flex-grow-this的 div)。似乎按设计工作。
标签: html css twitter-bootstrap flexbox bootstrap-4