【发布时间】:2016-10-11 09:01:50
【问题描述】:
我有一堆图片,是否可以不在 HTML 中定义任何内容,只在 CSS 中设置样式,以便它们出现在每行垂直对齐的多行中?以下代码有效,但.wrapper 无休止地排成一排,我希望在 5 或 6 张图像后有一个新行。
https://jsfiddle.net/qfb57a49/
css
.wrapper {
display: flex;
align-items: center;
}
html
<div class="wrapper ">
<img src="http://placehold.it/150x160" alt="">
<img src="http://placehold.it/150x120" alt="">
<img src="http://placehold.it/150x200" alt="">
<img src="http://placehold.it/150x70" alt="">
<img src="http://placehold.it/150x170" alt="">
<img src="http://placehold.it/150x150" alt="">
<img src="http://placehold.it/150x250" alt="">
<img src="http://placehold.it/150x110" alt="">
<img src="http://placehold.it/150x210" alt="">
<img src="http://placehold.it/150x110" alt="">
<img src="http://placehold.it/150x210" alt="">
</div>
【问题讨论】:
标签: html css flexbox vertical-alignment