简书链接:经典套路代码flex居中场景解决最后一行未铺满元素居中难看问题,伪元素实现最后一行填充剩余布局。
文章字数:36,阅读全文大约需要1分钟
image.png

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

.item-container {
padding-bottom:10px;
display: flex;
flex-direction: row;
flex-wrap: wrap;
}

.menu {
display: flex;
width: 25%;
flex-direction: column;
align-items: center;
padding-top:10px;
justify-content: center;
}
.item-container::after {
content: "";
background-color: red;
flex: auto;
}