使用flexbox,我如何将.bottom
div移动到窗口的底部? .boxContainer
的flex-direction
是column
,这样一切都可以垂直移动。我试过align-self: flex-end
和align-self: baseline
,但两者都是水平推动箱子,而不是垂直。我希望有人能帮我解决这个问题。使用flex在窗口的底部放置元素或框
.boxContainer {
\t width: 100vw;
\t height: 100vh;
\t background: peachpuff;
\t display: flex;
\t align-items: center;
\t justify-content: center;
\t flex-direction: column;
}
.center {
\t width: 300px;
\t height: 150px;
\t background: honeydew;
}
.bottom {
\t width: 300px;
\t height: 50px;
\t background: cyan;
\t align-self: flex-end;
}
<div class="boxContainer">
\t <div class="center"></div>
\t <div class="bottom"></div>
</div>
'ALIGN-items','ALIGN-self'并且沿着*横轴'ALIGN-content'工作*。 'justify-content'沿*主轴*工作。当你在'flex-direction:column'时,横轴是水平的,主轴是垂直的。这就是为什么'align-self'正在将您的物品左右移动。改用'justify-content'或'auto'边距。详情请参阅重复。 –