正如您在此处所见:JSFiddle
我希望作者div位于其父容器的底部。我试过align-self: flex-end;
,但它没有用。我做错了什么?
.flexbox {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
.item {
display: flex;
flex-direction: column;
width: 100px;
border: 1px solid #000;
padding: 10px;
}
.item .author {
width: 100%;
align-self: flex-end;
border: 1px solid #000;
}

<div class="flexbox">
<div class="item">
<div class="title">
Title
</div>
<div class="content">
Content
</div>
<div class="author">
Author
</div>
</div>
<div class="item">
<div class="title">
Title
</div>
<div class="content">
Content<br>Content
</div>
<div class="author">
Author
</div>
</div>
<div class="item">
<div class="title">
Title
</div>
<div class="content">
Content<br>Content<br>Content
</div>
<div class="author">
Author
</div>
</div>
</div>
&#13;
答案 0 :(得分:34)
尝试添加到.author
margin-top: auto;
您还需要删除flex-end。
答案 1 :(得分:6)
你可以在div之间创建一个包装div,它必须从flex start开始浮动。并且作者在包装器之外并且提供给.item
justify-content: space-between;
。
https://jsfiddle.net/0zq5a5xu/2/
.flexbox {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
.item {
display: flex;
flex-direction: column;
justify-content: space-between;
width: 100px;
border: 1px solid #000;
padding: 10px;
}
.wrapper {
display: flex;
flex-direction: column;
}
.author {
width: 100%;
border: 1px solid #000;
}
&#13;
<div class="flexbox">
<div class="item">
<div class="wrapper">
<div class="title">
Title
</div>
<div class="content">
Content
</div>
</div>
<div class="author">
Author
</div>
</div>
<div class="item">
<div class="wrapper">
<div class="title">
Title
</div>
<div class="content">
Content<br>Content
</div>
</div>
<div class="author">
Author
</div>
</div>
<div class="item">
<div class="wrapper">
<div class="title">
Title
</div>
<div class="content">
Content<br>Content<br>Content
</div>
</div>
<div class="author">
Author
</div>
</div>
</div>
&#13;
希望这有帮助。