【问题标题】:HTML Table with mixed fixed-width and fluid columns具有混合固定宽度列和流动列的 HTML 表格
【发布时间】:2012-03-05 06:35:47
【问题描述】:

我有一张使用table-layout:fixed 样式的表格。表格中有六列,我分别设置每列的宽度。对于某些列,其中的文本被截断。有没有办法根据内容设置特定列(一列或两列)的宽度?

【问题讨论】:

    标签: html html-table fluid-layout fixed-width


    【解决方案1】:

    使用column group 并使用以下语法将指定列的宽度设置为由内容确定的最小要求值:

    <table>
      <colgroup>
        <col width="30"><!--fixed width column-->
        <col width="0*"><!--minimum width of content column-->
      </colgroup>
      <tr>
        <td>
        <!--...-->
        </td>
      </tr>
    </table>
    

    【讨论】:

    • 我想根据内容设置一列的宽度,并为其他列硬编码宽度。
    • 在上述代码中,"30" 是硬编码的宽度,"0*" 是基于内容的宽度。
    猜你喜欢
    • 2012-07-15
    • 2021-10-26
    • 2012-01-01
    • 2018-09-05
    • 1970-01-01
    • 2016-04-13
    • 1970-01-01
    • 2014-02-10
    • 2017-05-22
    相关资源
    最近更新 更多