HTML表格不同行中的不同列数

Har*_*M V 37 html

我可以在Excel表格中使用

  1. 第1行中的2列
  2. 第2行中有1列长列

这有可能在HTML?

Dav*_*mas 91

在意识到你不熟悉的时候colspan,我认为你也不熟悉rowspan,所以我想我会把它扔进去.

需要注意的一点是,使用时rowspan:以下tr元素必须包含较少的td元素,因为rowspan在前一行(或前一行)中使用了单元格.

table {
  border: 1px solid #000;
  border-collapse: collapse;
}

th,
td {
  border: 1px solid #000;
}
Run Code Online (Sandbox Code Playgroud)
<table>
  <thead>
    <tr>
      <th colspan="2">Column one and two</th>
      <th>Column three</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td rowspan="2" colspan="2">A large cell</td>
      <td>a smaller cell</td>
    </tr>
    <tr>
      <!-- note that this row only has _one_ td, since the preceding row
                     takes up some of this row -->
      <td>Another small cell</td>
    </tr>
  </tbody>
</table>
Run Code Online (Sandbox Code Playgroud)

  • 发现这个演示非常有用:http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_table_span (2认同)

Niv*_*vas 18

colspan属性:

<table>
   <tr>
      <td> Row 1 Col 1</td>
      <td> Row 1 Col 2</td>
</tr>
<tr>
      <td colspan=2> Row 2 Long Col</td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)


oez*_*ezi 6

是的,只需使用colspan.