在 HTML table 中设置 colspan

Setting up colspan in HTML table

在弄清楚使用 colspan 时的网格是什么样子时遇到了一些问题,以便我可以均匀地对齐我的项目。

HTML

<table class="table MethodList" ng-repeat="method in api.methods">
   <tr>
      <td colspan=4 style="font-weight:bold">{{method.name}}</td>
      <td colspan=8>{{method.desc}}</td>
   <tr>
      <td colspan=4></td>
      <td colspan=8 style="background:#E6E6DA">{{method.parameters}}</td>
   </tr>
   <tr>
      <td colspan=4></td>
      <td colspan=8>{{method.additional}}</td>
   </tr>
   </tr>
</table>

这是做什么的

如您所见,后面的文字每一行都往后推,不知道为什么。我试图将初始值(索引、创建、确认、选择)保留为 colspan=4 中的唯一项,然后其他所有项都在这之后。

我也有 bootstrap,以防他们使用一些不错的模板。

您 table 末尾的结束 tr 标签 </tr> 似乎错位了。 请修复它并再次检查布局是否正确显示

你的代码应该变成这样:

<table class="table MethodList" ng-repeat="method in api.methods">
   <tr>
      <td colspan=4 style="font-weight:bold">{{method.name}}</td>
      <td colspan=8>{{method.desc}}</td>
   </tr>
   <tr>
      <td colspan=4></td>
      <td colspan=8 style="background:#E6E6DA">{{method.parameters}}</td>
   </tr>
   <tr>
      <td colspan=4></td>
      <td colspan=8>{{method.additional}}</td>
   </tr>
</table>