Created
July 5, 2023 11:25
-
-
Save dan-donica/ab54792f7dfce10347a1a36fc92d3e91 to your computer and use it in GitHub Desktop.
HC || Sticky Header - Javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Begin "Sticky Header" || Help center --> | |
<!-- Insert in Settings->Javascript->Footer --> | |
<!-- CS:20201028-12-1 --> | |
<script data-cfasync="false"> | |
document.addEventListener('DOMContentLoaded', stickyHeader); | |
window.addEventListener( 'resize', stickyHeader ); | |
function stickyHeader() { | |
var header = window.__page_generator ? document.querySelector('.section') : document.querySelector('.page-block'); | |
var headerHeight = header.clientHeight; | |
header.classList.add("sticky-header"); | |
document.querySelector('body').style.marginTop = headerHeight + 'px'; | |
} | |
</script> | |
<!-- End "Sticky Header" || Help center --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://help.instapage.com/hc/en-us/articles/217140498-Add-a-sticky-header-or-footer-to-your-page