flex瀑布流布局

1
2
3
4
5
6
7
8
9
10
<div class="masonry">
<div class="item">
<div class="item__content">
</div>
</div>
<div class="item">
<div class="item__content item__content--small">
</div>
</div>
</div>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
.masonry {
display: flex;
flex-flow: column wrap;
width: 100%;
height: auto;

/*缺点:需要设置一个固定的height*/
@media screen and (min-width: 400px) {
height: 1600px;
}

@media screen and (min-width: 600px) {
height: 1300px;
}

@media screen and (min-width: 800px) {
height: 1100px;
}

@media screen and (min-width: 1100px) {
height: 800px;
}
}