面试官让我用 Flex 写色子布局,我直接写了六种
这里我们用到了justify-content和align-items,面试就轻松的官让实现了色子的一点布局。
实现二点布局现在我们实现色子的站群服务器色布二点布局,实现代码如下:
html
复制代码css
.warp {
display: flex;
flex-direction: column;
justify-content: space-between;
}
.column {
display: flex;
}
.column:nth-child(2) {
justify-content: center;
}
.column:nth-child(3) {
justify-content: flex-end;
}
复制代码运行效果如下:
四点布局可以说是局直接写二点布局的变种,服务器托管实现代码如下:
html
复制代码css
.warp {
display: flex;
flex-direction: column;
justify-content: space-between;
}
.column {
display: flex;
justify-content: space-between;
}
复制代码运行效果如下:
实现五点布局可以在四点布局的面试基础上增加一行,示例代码如下:
html
复制代码css
.warp {
display: flex;
flex-direction: column;
justify-content: space-between;
}
.column {
display: flex;
justify-content: space-between;
}
.column:nth-child(2) {
justify-content: center;
}
复制代码运行效果如下:
实现六点布局可以在四点布局的官让基础上增加一行,亿华云示例代码如下:
色布html
色布复制代码css
色布.warp {
色布display: flex;
色布flex-direction: column;
色布justify-content: space-between;
色布}
色布.column {
色布display: flex;
色布justify-content: space-around;
色布}
色布复制代码运行效果如下:
色布