html - Firefox 在 <td> 标签之间添加水平间距

标签 html css

好吧,这可能是一个愚蠢的问题,但我正在尝试制作一个包含 3 列的表格,但 Firefox 在所有列之间添加了 1-2 像素的空间。该表在 Chrome 中看起来不错。我怎样才能消除这个额外的间距?使用开发工具检查时,我看不到这些空间。

<table role="presentation" align="center" cellpadding="0" cellspacing="0" width="100%" bgcolor="#F1F1F1" style="background:#F1F1F1; max-width:640px; border-spacing:-1; border-collapse:collapse; text-align:center;">
  <tr>
    <td style="display:inline-block; vertical-align:top; min-width:120px; width:33.33%;">
      <img id="IMG-small" src="https://picsum.photos/640/300?random=1" alt="" width="213" style="display:block;width:100%;height:auto;max-width:480px;margin:0 auto;" border="0">
    </td>
    <td style="display:inline-block; vertical-align:top; min-width:120px; width:33.33%;">
      <img id="IMG-small" src="https://picsum.photos/640/300?random=2" alt="" width="213" style="display:block;width:100%;height:auto;max-width:480px;margin:0 auto;" border="0">
    </td>
    <td style="display:inline-block; vertical-align:top; min-width:120px; width:33.33%;">
      <img id="IMG-small" src="https://picsum.photos/640/300?random=3" alt="" width="213" style="display:block;width:100%;height:auto;max-width:480px;margin:0 auto;" border="0">
    </td>
  </tr>
</table>

我正在为一些电子邮件营销开发这个,所以我不能使用任何类型的 JavaScript,而且任何高级 CSS 基本上都是不行的,因为我需要考虑范围广泛的电子邮件客户端。这也是我不使用 DIV 进行布局的原因。

我正在寻找的结果是让所有列都出现在单行中而不是换行。

最佳答案

由于您设置了 td { display: inline-block;,您看到的是 whitespace }。如果你真的需要它,解决它的一种方法是设置父元素的 font-size: 0;:

<table role="presentation" align="center" cellpadding="0" cellspacing="0" width="100%" bgcolor="#F1F1F1" style="background:#F1F1F1; max-width:640px; border-spacing:-1; border-collapse:collapse; text-align:center;">
  <tr style="font-size: 0;">
    <td style="display:inline-block; vertical-align:top; min-width:120px; width:33.33%;">
      <img id="IMG-small" src="https://picsum.photos/640/300?random=1" alt="" width="213" style="display:block;width:100%;height:auto;max-width:480px;margin:0 auto;" border="0">
    </td>
    <td style="display:inline-block; vertical-align:top; min-width:120px; width:33.33%;">
      <img id="IMG-small" src="https://picsum.photos/640/300?random=2" alt="" width="213" style="display:block;width:100%;height:auto;max-width:480px;margin:0 auto;" border="0">
    </td>
    <td style="display:inline-block; vertical-align:top; min-width:120px; width:33.33%;">
      <img id="IMG-small" src="https://picsum.photos/640/300?random=3" alt="" width="213" style="display:block;width:100%;height:auto;max-width:480px;margin:0 auto;" border="0">
    </td>
  </tr>
</table>

请记住为 td 元素的表格中的任何文本设置您实际需要的字体大小。

关于html - Firefox 在 <td> 标签之间添加水平间距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56383567/

相关文章:

flash - 是否可以在没有播放器的情况下始终对 MediaElement.js 进行换肤?

jquery - 如何使元素在手机屏幕上是一个在另一个下面

仅针对 firefox pc 的 css 媒体查询

jquery - div根据浏览器窗口大小显示

html - 这个空白区域是如何进入我的网站的?

css - 在 less 文件后导入 css

css - SVG 填充颜色不起作用

javascript - HTML5/jQuery 动画上的计时器/间隔

html - 具有可滚动主体和 colgroup 的表格不起作用

javascript - Bootstrap 4 Card Deck 固定卡片宽度(当每行卡片数量少于指定数量时)