I'm trying to display a table
which displays some grouped data.
The header should stick (at the top of the viewport), and also some table rows that contain the group titles.
For simplicity, I've created the following example on Codepen: https://codepen.io/andreivictor/pen/RwZRZav
The code I've tried is:
td.sticky {
background: red;
color: white;
position: sticky;
top: 50px; // this is the header height
}
Which works well on Chrome & Firefox.
The problem is that it doesn't work in Safari (tested on Safari v14); neither in Safari mobile. See the screenshot:
https://i.sstatic.net/08o4L.png - the row is sticky - but the top
position is different (relative to the top of the table - and not to top of the viewport).
top: 0
instead oftop: 50px
in your sticky class is working on safari? – Claritop: 0
- for safari /top: 50px
- for other browsers. But it looks like some kind of hack and I'm also trying to understand why this happens on safari. – Poi