The default vertical alignment of inline-blocks is baseline
. If there is text content, this refers to the baseline of the last line of that text. If there is no text content, this refers to an imaginary baseline at the bottom of the inline-block, hence the alignment you illustrated with your images. See also the following example:
.x {
display: inline-block;
width: 80px;
height: 120px;
border: 1px solid red;
}
<div class="x"></div>
<div class="x"></div>
<div class="x">aasd asd asd asd asd asd asd asd asd asd </div>
<div class="x">b</div>
<div class="x"></div>
If you want to avoid this, you can add vertical-align: top;
;
.x {
display: inline-block;
width: 80px;
height: 120px;
border: 1px solid red;
vertical-align: top;
}
<div class="x"></div>
<div class="x"></div>
<div class="x">aasd asd asd asd asd asd asd asd asd asd </div>
<div class="x">b</div>
<div class="x"></div>