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

我已经尝试改变边缘,填充,和各种边界属性的表和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>

当前回答

只是在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>

其他回答

只是在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>

对于td中的图像,使用这个:

display: block;

这为我消除了多余的空间

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

在本例中,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;
  border-spacing: 0;
}

对于符合标准的HTML5,添加所有这些css来删除表格中图像之间的所有空间:

table { 
    border-spacing: 0;
    border-collapse: collapse;
}
td {
    padding:0px;
}
td img {
    display:block;
}