我如何删除表中的行和列之间的额外空间。

我已经尝试改变边缘,填充,和各种边界属性的表和tr和td。

我希望所有的图片都是紧挨着的,看起来像一个大图像。

我该如何解决这个问题?

CSS

table {
  border-collapse: collapse;
}

HTML

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
  <title>Tera Byte Video Game Creation Camp</title>
  <link rel="stylesheet" type="text/css" href="style.css"></link>
</head>

<body>
  <table class="mytable" align="center">
    <tr class="header">
      <td colspan="3"><img src="images/home_01.png" /></td>
    </tr>
    <tr class="top">
      <td colspan="3"><img src="images/home_02.png" /></td>
    </tr>
    <tr class="link-row">
      <td><img src="images/home_03.png" /></td>
      <td><img src="images/home_04.png" /></td>
      <td><img src="images/home_05.png" /></td>
    </tr>
    <tr class="link-row">
      <td><img src="images/home_07.png" /></td>
      <td><img src="images/home_06.png" /></td>
      <td><img src="images/home_08.png" /></td>
    </tr>
    <tr class="link-row">
      <td><img src="images/home_09.png" /></td>
      <td><img src="images/home_10.png" /></td>
      <td><img src="images/home_11.png" /></td>
    </tr>
    <tr class="link-row">
      <td><img src="images/home_12.png" /></td>
      <td><img src="images/home_13.png" /></td>
      <td><img src="images/home_14.png" /></td>
    </tr>
    <tr class="bottom">
      <td colspan="3"><img src="images/home_15.png" /></td>
    </tr>
  </table>

</body>

</html>

当前回答

这招对我很管用:

#table {
  border-collapse: collapse;
  border-spacing: 0;
}

其他回答

我只需要加上一句:

line-height: 0px;

在我

<tr ...>

我有这个问题,几个帖子的建议都不起作用,我都试过了。我的问题是,我创建的表嵌套在另一个表中,继承了它的属性。我需要重写容器表。

在本例中,SuColTable是表上的类。

.SuColTable tr {
    border: none !important;
}

.SuColTable td {
    border-spacing: 0 !important;
    border: none !important;
    margin: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    padding-right: 0 !important;
}


.SuColTable {
    border-collapse: collapse !important;
    border: none !important;
    border-spacing: 0 !important;
    border-collapse: separate !important;
    padding-left: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}
// all padding would be padding: 0 !important

border-collapse, border:none和border-spacing删除表/行/列行。填充0调用从容器表中去除填充。为了覆盖容器表的样式,我必须在每个样式上都包含!important。

我有padding_top, left和bottom(而不是只有padding),因为我有另外两个类控制padding_right。

line-height: 0px;

行高0使第一行高。如果你有几行,它们被压缩成一行。

table 
{
    border-collapse: collapse;
}

将折叠分隔表列的所有边界…

或者尝试

<table cellspacing="0" style="border-spacing: 0;">

所有单元格间距为0,边界间距为0,以实现相同的效果。

玩得开心!

你有没有试过移除有colspan的tr,看看它是否改变了什么?

当涉及到精确的表设计时,我经历过colspan和rowspan非常糟糕。如果没有colspan-TRs,图像看起来还不错,我就从这里开始构建一个嵌套表。

此外,你的style.css似乎不完整,可能有什么问题?我至少要加上padding: 0;保证金:0;到表(或类“mytable”)。 确保你的图片没有空格和/或边框(例如添加img {border: 0;}到您的样式表)。

只是在Jacob的答案上加上,对于td中的img,

body {line-height: 0;}
img {display: block; vertical-align: bottom;}

这适用于大多数电子邮件客户端,包括Gmail。但Outlook不是。 对于outlook,你需要多做两步:

table {border-collapse: collapse;}

并设置每个td元素的高度和宽度与其包含的图像相同。例如,

<td width="600" height="80" style="line-height: 80px;">
    <img height="80" src="http://www.website.com/images/Nature_01.jpg" width="600" />
</td>