I am a beginner to CSS. I was trying to create a table in which the first column is of fixed width and must have a scrollbar with it. For the remaining column, I would like to them to spread evenly across the webpage.
I am able to create scrollbar for the first column, but it appears in every row, which is not what I want. I still want every first column to be scrollable, but the scroll bar should only appear once below the last row.
Anybody can help me on this?
#customers {
font-size: 10px;
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
border-collapse: collapse;
width: 100%;
table-layout: fixed;
}
#customers td,
#customers th {
border: 1px solid #ddd;
padding: 8px;
overflow-x: auto;
}
#customers tr:nth-child(even) {
background-color: #f2f2f2;
}
#customers tr:hover {
background-color: #ddd;
}
#customers th {
padding-top: 6px;
padding-bottom: 6px;
text-align: left;
background-color: #4CAF50;
color: white;
}
.col {
width: 3%;
}
<table id="customers">
<colgroup>
<col width=500px>
<col width=5% span="11">
</colgroup>
</table>