Elementor Change Header on Scroll With Smooth Animation

No extra plug-ins required! Elementor Pro Required.

To begin with, create your new header in a new section

It can be anywhere on the page. If you want the changing header on scroll on every page, then create it in your header template. Header templates are a Elementor Pro feature.

Then, give that section a CSS ID of ' menuhopin ' and a Z-Index of 999

Elementor Change Header on Scroll - With Smooth Animation

Finally, simply add the code below in an HTML Element

Adjust the transform:translateY value at the bottom of the code to match the approximate height of your header.


document.addEventListener('DOMContentLoaded', function() {
$(document).scroll(function() {
var y = $(this).scrollTop();
if (y > 300) { /* change this value here to make it show up at your desired scroll location. */
} else {
transform: translateY(0);
position: fixed;
width: 100vw;
-webkit-transition: transform 0.34s ease;
transition : transform 0.34s ease;
transform: translateY(-110px); /*adjust this value to the height of your header*/

Elementor Close PopUp on Click for Menu & Same Page Links
left html element

If you want your menu to show up only on desktop or mobile, simply use the Responsive settings

Easily Create a Responsive Elementor Mega Menu for FREE

If your menu is an horizontal bar at the top of the page, the above code will work perfectly

For any other placement, modify the CSS. If it needs to appear below something else, change the  top: 0;  value. If it is placed to the left or right of the page, remove width: 100vw;  and add left: 0; .

Et voila! Thanks for reading!

9 Responses

  1. Hey quick question, where does the HTML element go on the page? I tried to implement but the new navbar just stays on the page and there are no effects observed on scrolling.

      1. Michael Chan Hello Michael! You other header should not be set to 'fixed' or 'sticky' anymore. It should just be set to show up normally, at the top of the page!

      2. Hey Michael, can you tell us what you did to fix your issue? I can't seem to get my header to work and I suspect that it's because the html element is not placed in the correct space.

      3. Alexander Green I always put the HTML widget it in the footer so it applies to all pages

    1. Move the CSS part of the code to somewhere where it will load before the header ( for example in the wordpress customizer > additional CSS )

Leave a Reply