space between an inline-block element and a block element

前端 未结 2 1561
独厮守ぢ
独厮守ぢ 2021-01-26 10:33

What is that space between these two divs? I even removed the white space in html.

2条回答
  •  旧巷少年郎
    2021-01-26 10:58

    This appears to be caused by the vertical alignment. Where it's set to inline-block, by default the vertical alignment is set to baseline, which is slightly higher raised (probably to account for characters like 'y' and 'g' which dip below the line).

    vertical-align of top seems to fix it:

    #asd {
      ...
      vertical-align: top;
    }
    

    JSFiddle demo.

提交回复
热议问题