简体   繁体   English

如何删除HTML表格中行之间的分隔?

[英]How do I remove separation between rows in a HTML table?

I have a html table with 3 rows and 1 column. 我有3行1列的html表。 In the top and button row I have images and in the middle row I have div. 在顶部和按钮行中有图像,在中间行中有div。

Between my rows I see a separation (I see background of my page). 在行之间,我看到一个分隔(我看到了页面的背景)。 I tried to set all padding and margins to zero (for tables, div and images) and I still have this separation. 我试图将所有填充和边距设置为零(对于表格,div和图像),但我仍然有这种分隔。 Can anybody, please, help me to solve this problem. 谁能帮我解决这个问题。

Try using 'border-collapse': 尝试使用“边界折叠”:

table {
  border-collapse: collapse;
}

<table>标记中设置cellspacing=0以及cellpadding=0

在img标签中使用它:

display: block;

Gonzohunter nailed this, alright, but you may find it easier to just set the style on the table, assuming you are in a recent HTML version. 好的,Gonzohunter做到了这一点,但是假设您使用的是最新的HTML版本,则可能会发现在表上设置样式更容易。

I used 我用了

<table style='border-collapse: collapse;'>
    ... 
</table>

This worked perfectly. 这工作得很好。

It seems that it's your H2 that's causing it. 似乎是由您的H2引起的。 To fix it, set the top margin of it to zero: 要解决此问题,请将其上边距设置为零:

<h2 style="margin-top: 0;"><span class="text">Welcome to the Colored Trails Game Page!</span></h2>

You need to eliminate spacing from the table cells themselves. 您需要消除表格单元格本身的间距。

In CSS: 在CSS中:

<style type="text/css">
  td {
    border-collapse: collapse;
    border-spacing: 0;
    margin: 0;
    padding: 0;
  }
</style>

Or in HTML 4.01/XHTML 1.0 DTD (Strict or Transitional) : 或在HTML 4.01 / XHTML 1.0 DTD(严格或过渡)中

<table cellspacing="0" cellpadding="0">
  [...]
</table>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM