inline-block的意思是左右排列,宽高也有效的,然而,不设置inline-block设置左浮动也可以实现左右排列宽高有效,但他们肯定是有区别的,不同的场景可以用不同的方法。
<div style="width: 100px;height: 130px;background-color: olivedrab;display: inline-block"></div>
<div style="width: 100px;height: 135px; background-color: bisque;display: inline-block"></div>
<div style="width: 100px;height: 100px;background-color: rosybrown;display: inline-block"></div>
<br>
<div style="width: 100px;height: 130px;background-color: olivedrab;float: left"></div>
<div style="width: 100px;height: 135px; background-color: bisque;float: left"></div>
<div style="width: 100px;height: 100px;background-color: rosybrown;float: left"></div>
代码和图展现区别
1:使用使用inline-block的代码会有缝隙,因为在回车的过程中会产生空白符,想要消除空白符
2:在父级元素内插入font-size:0px即可,使用float:left的没有缝隙
使用float:left的是不齐的.inline-block是对齐的