【问题标题】:HTML table row height for single cell width单个单元格宽度的 HTML 表格行高
【发布时间】:2016-10-26 02:52:33
【问题描述】:

我正在尝试创建一个可以具有可变行数的表格,并且每行都有 1 个单元格宽度。

但是,在某些情况下,我希望一行具有几行的高度(例如 3 行)。我曾尝试为此使用 rowspan,但它似乎将前面的行包装到同一行中(不是我想要的)。

有没有办法处理单个单元格宽度表?

编辑:添加示例

    <table border="1">
        <tr>
            <td height="3">big</td>
        </tr>
        <tr>
            <td>small</td>
        </tr>
        <tr>
            <td>small</td>
        </tr>
        <tr>
            <td>small</td>
        </tr>
        <tr>
            <td>small</td>
        </tr>
</table>

【问题讨论】:

  • 如果表中只有一列,则行跨度没有意义。请尝试使用高度。
  • 我通过避免这一切来解决这个问题。我添加了一些新行(只包含一个空格),并删除了顶部/底部边框,使其看起来像 1 个大单元格

标签: html html-table


【解决方案1】:

单列是不可能的行跨度。如果您要在一个单元格中尝试多行,请使用 &lt;br/&gt;

【讨论】:

    【解决方案2】:

    我建议改用 CSS。

     <style>
         .big{
             height:100px;
         }
    
         .small{
            height:30px;
         }
     </style>
    
    
    
    <table border="1">
            <tr>
                <td class="big">big</td>
            </tr>
            <tr>
                <td class="small">small</td>
            </tr>
            <tr>
                <td class="small">small</td>
            </tr>
            <tr>
                <td class="small">small</td>
            </tr>
            <tr>
                <td class="small">small</td>
            </tr>
    </table>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-08-14
      • 1970-01-01
      • 2016-01-27
      • 2013-03-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多