Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DiviThemeExamples/4157272a6bde0707141d1ffa4867296e to your computer and use it in GitHub Desktop.
Save DiviThemeExamples/4157272a6bde0707141d1ffa4867296e to your computer and use it in GitHub Desktop.
Make Divi Theme Builder header sticky
<script>
// When the user scrolls down 50px from the top of the document, resize the header's font size
window.onscroll = function() {scrollFunction()};
function scrollFunction() {
if (document.body.scrollTop > 100 || document.documentElement.scrollTop > 100) {
document.getElementById("myheader").style.position = "fixed";
} else {
document.getElementById("myheader").style.position = "";
}
}
</script>
// tutorial @ https://www.divithemeexamples.com/make-your-divi-4-0-header-sticky-or-fixed-with-the-theme-builder/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment