【发布时间】:2016-01-06 03:01:54
【问题描述】:
我有一个弹性容器 .container 和两个弹性项目:item-one 和 item-two。我想将第一个项目垂直居中并将第二个项目放在底部。
我不知道如何在这种情况下垂直对齐第一项。
HTML:
<div class="container">
<div class="item-one">Item One</div>
<div class="item-two">Item Two</div>
</div>
CSS:
html, body {
height: 100%;
margin: 0;
}
.container {
width: 500px;
margin: 0 auto;
border: 5px solid orange;
height: 100%;
/* Flex properties */
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: center;
}
.item-one {
border: 5px solid yellow;
flex-basis: 500px;
}
.item-two {
border: 5px solid red;
align-self: flex-end;
}
【问题讨论】: