简体   繁体   English

为什么使用这种标准语法会得到奇怪的html表结果?

[英]Why am I getting odd html table results with this standard syntax?

I'm using this code on my wordpress site but I'm getting odd results. 我在wordpress网站上使用此代码,但结果却很奇怪。 I want to divide the table row into two columns, but I've ended up just gluing an extra bit on the side. 我想将表格行分为两列,但最后只在侧面粘贴了一点。 what am I doing wrong? 我究竟做错了什么?

<table>
 <tr>
  <td style="padding:0px;">
deleted the content to make this less to read
  </td>
 </tr>

 <tr>
  <td style="padding:0px;">
this is a test
  </td>
  <td style="padding:0px;">
as is this
  </td>
 </tr>

 <tr>
  <td style="padding:0px;">
deleted the content to make this less to read
  </td>
 </tr>

 <tr>
  <td style="padding:0px;">
deleted the content to make this less to read
  </td>
 </tr>

 <tr>
  <td style="padding:0px;">
deleted the content to make this less to read
  </td>
</tr>
</table>

and I get this weird little bit off the edge rather than the split I want: 我从边缘得到了一些奇怪的东西,而不是我想要的分割:

请注意,上面写着“是这样”

Is it something to do with the aligned right image content in the table below possibly? 可能与下表中对齐的右图像内容有关吗?

The number of columns in a table must be constant. 表中的列数必须恒定。

Add colspan="2" to your single cells. colspan="2"添加到您的单个单元格中。

A table has as many columns as the row with the most columns in it. 一个表的列数与其中最多列的行数相同。 If cells are missing from other rows, then they are left out from the rendering and cells are not stretched to fit. 如果其他行中缺少单元格,则将它们从渲染中排除,并且单元格不会拉伸到适合的程度。

Use colspan to make a cell take up multiple columns. 使用colspan使一个单元格占用多列。

In your case, you don't appear to have tabular data at all, so don't use a table in the first place. 就您而言,您似乎根本没有表格数据,因此请不要首先使用表格。

Your second row is two columns wide, but the remaining rows are still just one column in width. 您的第二行是两列宽,但是其余行的宽度仍然仅为一列。 Either add a second column to each of the other rows, or extend the cells in the other columns so that they cover two columns, like this: 将第二列添加到其他每行中,或者扩展其他列中的单元格,使其覆盖两列,如下所示:

 <tr>
  <td style="padding:0px;" colspan=2>
deleted the content to make this less to read
  </td>
 </tr>

You'll need to do that for all the rows with just one column. 您需要对只有一列的所有行执行此操作。

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

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