html - td 中的多行

标签 html html-table

专卖店 <td>包含具有多行的表。一个商店可以有多个
存储(行)。

参见示例:https://jsfiddle.net/ak3wtkak/1/

Stores 和 Quantity ( <th> ) 列的宽度对于第二个表上的多行应该相同。如何解决这个问题或什么是替代方法?

enter image description here

<table border="1" width="100%">
  <thead>
    <tr>
      <th style="width:300px">Product</th>
      <th>Barcode</th>
      <th>Stores</th>
      <th class="middle">Quantity</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
      Item 1
      </td>
      <td>12345</td>
      <td colspan="3">
        <table border="1" width="100%">
          <tbody>
            <tr>
              <td>Store Name 1</td>
              <td class="middle">4</td>
            </tr>
            <tr>
              <td>Store Name 2</td>
              <td class="middle">4</td>
            </tr>
            <tr>
              <td>Store Name 3</td>
              <td class="middle">4</td>
            </tr>
          </tbody>
        </table>
      </td>
    </tr>
  </tbody>
</table>

最佳答案

您必须使用 rowspan。
使用 rowspan 为 3 制作前 2 行。

<table border="1" width="100%">
  <thead>
    <tr>
      <th style="width:300px">Product</th>
      <th>Barcode</th>
      <th>Stores</th>
      <th class="middle">Quantity</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td rowspan="3">Item 1</td>
      <td rowspan="3">12345</td>
      <td>Store Name 1</td>
      <td>4</td>
    </tr>
    <tr>
      <td>Store Name 2</td>
      <td>4</td>
    </tr>
    <tr>
      <td>Store Name 3</td>
      <td>4</td>
    </tr>
  </tbody>
</table>

关于html - td 中的多行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42949132/

相关文章:

javascript - 如何在java脚本中制作倒数计时器,它不应该在页面重新加载时重置

html - 如何设置图标旁边的列表和段落的样式?

html - 表格列在 chrome 中失去宽度

javascript - 相同的表数据 rowspan html css

php - 在每第三个循环后插入 tr

javascript - 如果单元格[X]已写入输入,则从行中获取值

html - 如何取消子 div 的不透明度?

html - 在多个元素上触发悬停

java - 如何使用 java servlet 从 mysql 数据库中检索图像并将其显示在 HTML img 标签中?

html - 如何在此特定标题上居中对齐 Logo