JAVASCRIPT 26
Elementor Sticky Header on scroll up By micha on 14th March 2025 09:30:05 AM
  1. 1. Set sticky option to the header element
  2. 2. Add ID and Classes to the Header Container
  3. 3. Add Code to Elementor → Custom Code
  4.  
  5.  
  6. <!-- Hide and Show Desktop Header -->
  7. <script>
  8. var prevScrollpos = window.pageYOffset;
  9. window.onscroll = function() {
  10. var currentScrollPos = window.pageYOffset;
  11.   if (prevScrollpos > currentScrollPos) {
  12.     document.getElementById("sticky-header").style.top = "0";
  13.   } else {
  14.     document.getElementById("sticky-header").style.top = "-80px"; /* adjust this value to the height of your header */
  15.   }
  16.   prevScrollpos = currentScrollPos;
  17. }
  18. </script>
  19.  
  20. <style>
  21. /* Show Hide Sticky Header Speed Control */
  22. #hide-header {
  23.         transition: all .4s ease!important;
  24. }
  25. </style>

Paste is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.