【问题标题】:colgroup is not working on html5colgroup 不适用于 html5
【发布时间】:2017-06-17 22:15:24
【问题描述】:

我尝试使用 colgroup 为表格的每一列赋予宽度,但它不起作用。示例代码在这里

<table>
    <colgroup width="100%">
       <col style="width: 5%; background-color: red">
       <col style="width: 15%;">
       <col style="width: 25%;">
       <col style="width: 20%;">
       <col style="width: 10%;">
       <col style="width: 15%;">
       <col style="width: 10%;">
    </colgroup>
    <tr>    
        <th> no </th>
        <th>Reference No</th>
        <th>Vendor Name</th>
        <th>Vendor Name</th>
        <th>Vendor Name</th>
        <th>Vendor Name</th>
        <th>Vendor Name</th>    
    </tr>
</table>

【问题讨论】:

    标签: html html-table


    【解决方案1】:

    http://www.w3schools.com/TAgs/tag_colgroup.asp

    HTML5 不支持 HTML 4.01 [in col group] 中的大多数属性。

    这包括宽度属性。

    【讨论】:

    • 虽然不是一个“替代方案”,但您可以创建一组 CSS 类,然后将它们应用于每个 &lt;th&gt; 元素。这应该处理所有后续行的宽度,但如果你也想要background-color,那么我认为你还必须将 CSS 类添加到每个 &lt;td&gt;
    猜你喜欢
    • 1970-01-01
    • 2013-01-26
    • 1970-01-01
    • 1970-01-01
    • 2016-12-15
    • 1970-01-01
    • 1970-01-01
    • 2019-08-06
    • 2017-12-12
    相关资源
    最近更新 更多