HTML表rowspan

时间:2014-05-29 11:29:29

标签: html

我有一张如下表(左侧) - 如何让它像右边那样?

enter image description here

    <table>
        <thead>
          <tr>
              <td colspan='3' rowspan='2'>Lorem</td>
              <td>1</td>
          </tr>
          <tr>
              <td>2</td>
          </tr>
          <tr>
              <td>A</td>
              <td>B</td>
              <td>C</td>
          </tr>
       </thead>
    </table>

3 个答案:

答案 0 :(得分:1)

像这样:

<table>
  <thead>
    <tr>
      <td colspan='3'>Lorem</td>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>A</td>
      <td>B</td>
      <td>C</td>
    </tr>
  </tbody>
</table>

答案 1 :(得分:0)

这是你的代码!!

<强> HTML

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="css/all.css"/>
    <title>STACKOVERFLOW</title>
</head>
<body>
<table>
    <tr>
        <td colspan="3">Lorem</td>
    </tr>
    <tr>
        <td>A</td>
        <td>B</td>
        <td>C</td>
    </tr>
</table>
</body>
</html>

<强> CSS

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

答案 2 :(得分:0)

<table>
        <thead>
          <tr>
              <td colspan='3'>Lorem</td>

          </tr>

          <tr>
              <td>A</td>
              <td>B</td>
              <td>C</td>
          </tr>
       </thead>
    </table>