【发布时间】:2019-06-23 13:25:36
【问题描述】:
当我将 flex-container 高度设置为大于 flex-items 占用的高度时,包裹的项目之间会有空间。请注意 - justify-content 和 align-items 都设置为 flex-start。这里是sn-p(运行后点击整页)
.flex-container {
min-height: 100vh;
position: relative;
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: flex-start;
flex-wrap: wrap;
}
header,
main,
aside,
footer {
padding: 1rem;
background-color: tomato;
}
header,
footer {
width: 100%;
}
main {
width: 75%;
}
aside {
flex-grow: 1;
}
<div class="flex-container">
<header>Header Content</header>
<main>Main content here.</main>
<aside>Sidebar content</aside>
<footer>Footer Content</footer>
</div>
如果你颠倒了所有的属性,这可以用flex-direction: column; 复制。这是预期的行为吗?如果是这样,为什么?有没有办法解决这个问题并得到类似的东西:
将 flex-container 高度设置为 100vh ?
【问题讨论】: