今天用到弹性布局的时候,不小心忽略了弹性布局分为容器属性和项目属性
就比如我想让三个class=box的div在一行显示,我写了如下代码
.box{
width: 100px;
height: 100px;
border: 1px solid red;
background-color: blue;
display: flex;
}
然而display:flex是应该设置给div父元素的属性,也就是容器的属性,应该这样写
body{
display: flex;
}
.box{
width: 100px;
height: 100px;
border: 1px solid red;
background-color: blue;
}
发现对弹性布局掌握并不熟练,于是来做个总结