flex实现从上到下,从左到右排序
正常来说,想要实现从上到下,从左到右排序,很多朋友不会的都跑去使用JS实现,实际上使用Flex布局轻松实现。主要就flex-wrap: wrap,允许换行 和 flex-direction: column,主轴方向切换位Y轴。
.container {
display: flex;
flex-wrap: wrap;
flex-direction: column;
height: 300px;
gap: 10px;
border: 4px solid red;
}
.item {
display: flex;
align-items: center;
justify-content: center;
width: 300px;
height: 30px;
color: white;
font-weight: 700;
font-size: 16px;
background-color: rgb(19, 195, 244);
}