I came across this HTML structure
.table {
display: table;
}
.row {
display: table-row;
}
.cell {
display: table-cell;
text-align: center;
padding: 5px;
border-right: 1px solid #ddd;
border-bottom: 1px solid #ddd;
}
.sticky {
position: -webkit-sticky;
position: sticky;
top: 0px;
background: red;
}
<body>
<div class="table">
<div class="row">
<div class="cell sticky"><span>Header Row 1</span>
</div>
</div>
<div class="row">
<div class="cell sticky"><span>Header Row 2</span>
</div>
</div>
<div class="row">
<div class="cell">Detail Row 1</div>
</div>
<div class="row">
<div class="cell">Detail Row 2</div>
</div>
<div class="row">
<div class="cell">Detail Row 3</div>
</div>
</div>
</body>
It successfully makes the second Header Row sticky, just as intended. However, I am wondering how to make both Header Rows sticky on top of each other. This way, both rows remain visible when the user scrolls the page.