Possible Duplicate:
Unwanted margin in inline-block list items
A Space between Inline-Block List Items
为了避免 li
设置为 display: inline-block
之间的差距,我将 ul
的字体大小设置为0. 因此 em 大小的性质,0 现在作为所有 li
的基本字体大小传递,这实际上意味着人们看不到它们。
有没有办法在不为列表项设置font-size: 14px
(例如)的情况下解决这个问题?
Just float them instead Maybe they don't need to be inline-block at
all, maybe they can just be floated one way or another. That allows
you to set their width and height and padding and stuff. You just
can't center them like you can by text-align: center; the parent of
inline-block elements.
看看这个来源:http://css-tricks.com/fighting-the-space-between-inline-block-elements/
它列出了您的问题的多种解决方案。 避免将字体大小设置为 0;