【发布时间】:2020-10-26 13:44:49
【问题描述】:
我正在使用 flex 在 div(容器)中水平显示元素。这些元素都应该 1. 右下对齐并且 2. 拉伸整个高度。我可以实现 1. 单独和 2. 单独但不能一起实现,它们似乎冲突并且拉伸似乎覆盖了底部对齐。
有没有一种方法可以让我的内部元素实现右下对齐并让它们伸展到整个高度?注意我真的不能添加另一个 div 来包装元素。
.container {
display: flex;
flex-direction: row;
/* Align inner elements right and bottom */
align-items: flex-end;
justify-content: flex-end;
border: solid 1px red;
}
.container > * {
border: solid 1px blue;
/* Make inner elements stretch full height*/
align-self: stretch;
}
<div class="container" style="height: 500px;">
<a href="/#"><p><span>This should be bottom right aligned</span></p></a>
<p><span>This should be bottom right aligned</span></p>
<p><span>This should be bottom right aligned</span></p>
<div>
<a href="/#"><span>Dropdown Btn</span></a>
</div>
</div>
【问题讨论】: