位置:绝对;如何实现?和 colgroup 标签一起工作吗?

not*_*off 6 html css position colgroup

我的最终目标是创建一个表,该表的第一列保持不变,但其他列水平滚动。我找到了一些其他解决方案,但很好奇为什么 colgroup 和 Absolute 似乎不能一起工作。

html

<!DOCTYPE html>
<html>
<head>
    <link href="main.css" rel="stylesheet">
    <title>Test Table</title>
</head>
<body>

    <p>Table with colgroup and col</p>
    <div class = "container">
    <table>
      <colgroup>
        <col class="column1">
        <col class="columns2plus3" span="2">
      </colgroup>
      <tr>
        <th>Lime</th>
        <th>Lemon</th>
        <th>Orange</th>
      </tr>
      <tr>
        <td>Green</td>
        <td>Yellow</td>
        <td>Orange</td>
      </tr>
    </table>
    </div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

CSS

table {
    width: 400px;
    table-layout: fixed;
    border: 1px solid purple;
}

.container {
    width : 300px;
    overflow: scroll;
}

td, th{
    border: 1px solid black;
    width: 50px;
}


.column1 {
    background-color: red;
    width: 200px;
/*  position: absolute;
    left: 0;*/
}


.columns2plus3 {
    width: 400px;
    padding-left: 500px;
}
Run Code Online (Sandbox Code Playgroud)

当我取消注释位置并离开时,红色不再出现。