The other answers provide solutions, but not the why this happens:
Some given funny joke
-----^---------^-^
In that string I've marked three characters. Those three have so called 'decenders' (e.g.: the loop under the G, the legs under the Y and J).
When you declare something inline-block
, it gets the properties of both block
and inline
elements. The inline elements are often text (e.g. a
or span
), thus have decenders, thus your div has room for decenders.
This is why setting line-height:0; font-size:0;
does the trick.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…