表格(下)设置宽度,列颜色

学习要点:设置表格每一列的颜色(col标签),以及每一列的宽度(colgroupcol标签)。

效果如下:

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta charset="utf-8">

</head>
<body>
<table border="1">
    <caption>单元格</caption>
    <colgroup span="1" style="width:300px">
    <col style="background-color: blue">
    </colgroup>
    <colgroup span="2" style="width:150px">
    <col style="background-color: gold">
        <col style="background-color: gold">
    </colgroup>
    <colgroup span="1" style="width:300px">
        <col style="background-color: green">
        </colgroup>

    <!--此时的数字代表几列-->
    <thead>
    <tr><th>标题一</th><th>标题一</th><th>标题一</th><th>标题一</th></tr>
    </thead>
    <tr><td >yuan</td><td>yuan</td><td>yuan</td><td>yuan</td></tr>
    <tr><td>yuan</td><td>yuan</td><td>yuan</td><td>yuan</td></tr>
    <tr><td>yuan</td><td>yuan</td><td>yuan</td><td>yuan</td></tr>
    <tfoot>
    <tr><td>yuan1</td><td>yuan</td><td>yuan</td><td>yuan</td></tr>
    </tfoot>
</table>
</body>
</html>

 注意<colgroup span="1">中的数值代表的意思是几列,而不是第几列。

猜你喜欢

转载自blog.csdn.net/qq_41666208/article/details/81084699
今日推荐