Share a weird css issue I met today, that isthere are always some space between inline-block
div elements of a line. For these div elements, margin are confirmed to be 0. See how it looks in
the top part of below snapshot.
And below is corresponding code snippet,
After some time on googling, the root cause was located; It’s the whitespace between inline-block div elements. In the above code, whitespace
is newline character.
Two solutions can be used to fix this issue. One is eliminating whitespace, like
The other is to use display:table-cell;, which may be better than former method, since it does
not hurt your beautiful format.
Space Between inline-block Elements
Share a weird css issue I met today, that isthere are always some space between
inline-block
div elements of a line. For these div elements,margin
are confirmed to be0
. See how it looks in the top part of below snapshot.And below is corresponding code snippet,
After some time on googling, the root cause was located; It’s the whitespace between
inline-block
div elements. In the above code, whitespace isnewline
character.Two solutions can be used to fix this issue. One is eliminating whitespace, like
The other is to use
display:table-cell;
, which may be better than former method, since it does not hurt your beautiful format.Reference here. Code for above snapshot here.
如果你觉得这篇文章对你有用,可以微信扫一扫表示🙏 / If you find this post is useful to you, buy me 🍶 via Wechat