tablehead sticky au scroll

This commit is contained in:
Valentin
2023-07-04 22:31:53 +02:00
parent 87d982ed34
commit 7c1ff8501e
2 changed files with 11 additions and 2 deletions
+9
View File
@@ -34,6 +34,15 @@
for (let otherTableTd of otherTableTds) {
otherTableTd.style.width = `${100 / 8 * 1.75}%`;
}
// HEADER AU SCROLL
let tableHead = document.querySelector("thead tr");
let tHeadHeight = tableHead.offsetHeight;
window.onscroll = () => {
tableHead.style.minHeight = `${document.querySelector("header").offsetHeight + 72}px`;
let scroll = window.pageYOffset;
let headerNewHeight = tHeadHeight - scroll;
tableHead.style.height = `${headerNewHeight}px`;
}
}, false);
</script>