来源:https://blog.csdn.net/ly_solo/article/details/79798859
<div class="main" style=" margin:auto; width:100%; height:102px; border:solid 1px #000000;">
<div class="sub1" style=" width:32%; height:100px; border:solid 1px blue; float:left; margin-left:1%;"></div>
<div class="sub1" style=" width:32%; height:100px; border:solid 1px red; float:left; margin-left:1%;"></div>
<div class="sub1" style=" width:32%; height:100px; border:solid 1px yellow; float:left; margin-left:1%;"></div>
</div>
- 子块需要设置
width
- 子块设置
float
为 left - 父块设置
margin: auto