1、布局效果
![](https://img-blog.csdnimg.cn/direct/0dc528c6ecc74c9c8341a67f2926e7a4.png)
2、css布局样式
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>测试弹性盒子</title>
</head>
<body>
<div class="out-parent">
<div class="share-item"><div style="margin: auto">1</div></div>
<div class="share-item"><div style="margin: auto">2</div></div>
<div class="share-item"><div style="margin: auto">3</div></div>
<div class="share-item"><div style="margin: auto">4</div></div>
</div>
</body>
<style>
/**将父容器作为一个弹性盒子,左中右弹性布局*/
.out-parent {
display: flex;
background: aquamarine;
width: 100%;
height: 200px;
margin-top: 20px;
}
.share-item{
flex: 1;
background: chartreuse;
height: 100%;
margin-left: 10px;
margin-right: 10px;
display: flex;
justify-items: center;
align-items: center;
}
</style>
</html>