我的照片下面有可变长度的文字。我正在使用flexbox让它们正确对齐,并使用flex-grow设置宽度,使它们相等。这适用于包装的行,但最后一行可以拉伸以适合整行。
我怎样才能平均每一行,并从左侧开始?
.container {
display: flex;
flex-wrap: wrap;
}
a {
text-align: center;
padding: 25px;
flex: 1 1 0;
}
<div class="container">
<a href="https://placeholder.com">
<img src="http://via.placeholder.com/100x100">
<p>
Brian
</p>
</a>
<a href="https://placeholder.com">
<img src="http://via.placeholder.com/100x100">
<p>
Betsy
</p>
</a>
<a href="https://placeholder.com">
<img src="http://via.placeholder.com/100x100">
<p>
Variable Length Names Go Here
</p>
</a>
<a href="https://placeholder.com">
<img src="http://via.placeholder.com/100x100">
<p>
Alan
</p>
</a>
<a href="https://placeholder.com">
<img src="http://via.placeholder.com/100x100">
<p>
Another variable length
</p>
</a>
<a href="https://placeholder.com">
<img src="http://via.placeholder.com/100x100">
<p>
Another variable length
</p>
</a>
</div>