html - 制作不相同的表行(表中表中的表)

标签 html css html-table css-tables

我在创建与其上方的行不同的行时遇到问题。 我想要一行有 3 个单元格,在这一行下面扩展到行尾,依此类推。第一行 - 3 个单元格,第二行 - 1 个长单元格(长度等于上面三个单元格)并重复。

这是我使用的 HTML 和 CSS 模板

#table {
  margin: 0px;
  margin-left: 585px;
  margin-top: 50px;
  z-index: 2;
  width: 385;
  border-collapse: collapse;
}

.divStyle {
  /* in charge of the scroller*/
  width: 385px;
  height: 428px;
  overflow: auto;
}

.innerTables {
  width: 360;
  border-collapse: collapse;
  vertical-align: middle;
}

.productionTable tr td {
  width: 360px;
  border: 2px solid black;
}

.innerTables tr td,
th {
  margin: 0px;
  padding: 0px;
  width: 120px;
}

.innerTables tr td {
  border: 1px solid black;
}
<table id='table'>
  <tr>
    <td>
      <table class='innerTables'>
        <tr>
          <th>Building</th>
          <th>Amount</th>
          <th>1 Per</th>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td>
      <div class='divStyle'>
        <table class='innerTables'>
          <tr>
            <td>Fishery</td>
            <td class='inputText' id="fishery"></td>
            <td>800 Farmers</td>
          </tr>
          <tr>
            <td colspan="0">
              <table class='productionTable'>
                <tr>
                  test
                </tr>
              </table>
            </td>
          </tr>
        </table>
      </div>
    </td>
  </tr>
</table>

我尝试使用边框来指示它是否有效。

This is what I try to achieve

This is what I achieve

最佳答案

使用colspan扩展列宽

我给你做了一个 fiddle https://jsfiddle.net/vzy97s2a/

                    <tr>
                      <td colspan="3">
                        wider
                      </td>
                    </tr>

关于html - 制作不相同的表行(表中表中的表),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55867729/

相关文章:

jquery - 防止多次点击,直到记录被删除

javascript - 在表中的特定td下添加项目

javascript - 为 JavaScript 函数添加延迟

javascript - 在 onDeviceReady 中调用时函数无法正常工作

css - 托管网络字体、CDN、@font-face 和隐私

jquery - Bootstrap 下拉菜单项大小不变

css - 使用 CSS 而不是带循环的 gif 动画

CSS 响应表未显示

javascript - 媒体查询适用于 chrome 和 Firefox 桌面,但不适用于移动设备

html - 将鼠标悬停在表格单元格边框上时显示工具提示