如何消除内联元素之间的空格的可见性?
假设我有几个内联块 div 标签,就像此类
<div class="image">
</div>
<div class="image">
</div>
图像只是将其大小设置为 100x100 和灰色背景颜色。它们的边距和边框设置为 0,但两个矩形之间有间距。
但是,如果我编写这样的 HTML:
<div class="image">
</div><div class="image">
</div>
删除 div 之间的所有空白,间距就会消失。
因为我不想这样编写 HTML,所以我认为必须有一种方法可以使用 CSS 删除空格。我不在乎空白是否被删除、隐藏或缩小,只要它的可见性被删除即可。
感谢您的帮助
根据要求,JSFiddle: http://jsfiddle.net/6h3Jx/
已更新字间距: http://jsfiddle.net/6h3Jx/1/
Say I have several inline-block div tags, like this
<div class="image">
</div>
<div class="image">
</div>
class image just sets their size to 100x100 and a gray background color. Their margin and borders are set to 0, and yet there is spacing between the two rectangles.
If I write the HTML such as this, however:
<div class="image">
</div><div class="image">
</div>
Removing all whitespace between the divs, the spacing disappears.
Since I don't want to write my HTML like that, I'm thinking that there must be a way to remove whitespace using CSS. I don't care if the whitespace is removed, hidden or downsized as long as it's visibility is removed.
Thanks for any help
As requested, JSFiddle: http://jsfiddle.net/6h3Jx/
Updated with word-spacing: http://jsfiddle.net/6h3Jx/1/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是一种内联元素行为,因此请尝试向左浮动。 http://jsfiddle.net/aVrSx/
it is an inline element behaviour, so try floating left. http://jsfiddle.net/aVrSx/
您可以设置“显示:flex;”属性到其父包装器:
you can set "display: flex;" attribute to their parent wrapper:
将以下内容放在父元素上:
或者尝试:
它可能会工作得更好,因为它不会受到文本大小调整的影响。
put the following on a parent element:
Or try:
It might work even better as it will not be affected by text resizing.