首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >表行填充剩余高度Chrome与Firefox

表行填充剩余高度Chrome与Firefox
EN

Stack Overflow用户
提问于 2019-09-25 18:35:13
回答 2查看 133关注 0票数 0

我有一个代码,它在Firefox和Chrome上的行为是不同的。

我想要的行为就是Firefox上的行为。我想在Chrome上重现它,但没有成功。

在下面的代码中,想法是tr class="spacer"填充tr class="family"行下面的剩余高度,以便它们将显示在tr class="category"行的顶部。

在Chrome上,这是完全不一致的。

代码语言:javascript
运行
复制
.category th {
  height: 200px;
  background: red;
}

.family {
  height: 70px;
  background: blue;
}
代码语言:javascript
运行
复制
<table>
  <tbody>
    <tr>
      <th>Category</th>
      <th>Family</th>
      <th>Info</th>
    </tr>

    <tr class="category">
      <th rowspan="3">Category 1</th>
    </tr>
    <tr class="family">
      <td>Family 1</td>
      <td>Many different things</td>
    </tr>
    <tr class="spacer">
      <td colspan="3"></td>
    </tr>

    <tr class="category">
      <th rowspan="4">Category 2</th>
    </tr>
    <tr class="family">
      <td>Family 2</td>
      <td>Other things</td>
    </tr>
    <tr class="family">
      <td>Family 3</td>
      <td>Way more things</td>
    </tr>
    <tr class="spacer">
      <td colspan="3"></td>
    </tr>
  </tbody>
</table>

EN

Stack Overflow用户

发布于 2019-09-25 18:57:47

根据这个例子https://www.w3schools.com/tags/att_td_rowspan.asp,我像这样重写你的代码。希望这能对你有所帮助。

代码语言:javascript
运行
复制
<html>

<head>
  <style>
    .custom th {
      height: 200px;
      background: red;
    }
    
    .custom td {
      height: 70px;
      background: blue;
    }
  </style>
</head>

<body>
  <table>
    <tbody>
      <tr>
        <th>Category</th>
        <th>Family</th>
        <th>Info</th>
      </tr>

      <tr class="custom">
        <th rowspan="3">Category 1</th>
        <td>Family 1</td>
        <td>Many different things</td>
      </tr>
      <!-- Add 2 spacer for enough 3 row because rowspan = 3 -->
      <tr class="spacer">
        <td colspan="3"></td>
      </tr>
      <tr class="spacer">
        <td colspan="3"></td>
      </tr>

      <tr class="custom">
        <th rowspan="4">Category 2</th>
        <td>Family 2</td>
        <td>Other things</td>
      </tr>
      <tr class="custom">
        <td>Family 3</td>
        <td>Way more things</td>
      </tr>
      <tr class="spacer">
        <td colspan="3"></td>
      </tr>
      <tr class="spacer">
        <td colspan="3"></td>
      </tr>
    </tbody>
  </table>
</body>

</html>

票数 1
EN
查看全部 2 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58096464

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档