Within my system, I have organized two tables: table one and table 2 are stacked on top of each other. I've managed to freeze the column headers so that they are displayed vertically, remaining static as users scroll horizontally. To achieve this effect, I used a sticky attribute in the th element within the CSS code. Both tables are enclosed under one div with the assigned class "scrollHorizontal," which should allow both tables to move together when users scroll horizontally. However, an issue arises where only the column from the first table sticks when scrolling horizontally, while the second table remains unaffected. I am seeking insight into the underlying reason for this behavior.
Screenshot: https://i.stack.imgur.com/xk8dL.png
th {
padding: 7px;
position: sticky;
left: 0px;
min-width: 250px;
width: 250px;
background-color: #f5f7f7;
}
td {
padding: 7px;
min-width: 300px;
width: 300px;
/* max-width: 300px; */
}
/* Additional CSS classes... */
.scrollHorizontal {
overflow-x: scroll;
}
<!-- HTML layout containing the tables -->