In this tutorial, you will learn how to close the new Elementor Off Canvas element when clicking any anchor menu links within it.
Let's get started!
First, add this code on the same page as your Elementor off canvas with anchor links
Often, this will be in your header template. Just add it at the same place where your Off Canvas element is.
Add a new HTML element, and copy paste this code in it.
<script> /* Please login to get the code * The code will be for the Elementor Close Off Canvas On Anchor Link Click tutorial * Found at this URL https://element.how/elementor-close-off-canvas-on-anchor-link-click/ */ </script>
Then, go under Advanced > Positioning for the HTML element
Go under Advanced > positioning, and set the HTML element to position absolute. This is just to avoid having it taking flow space. You will be able to find it back easily through the navigator.
Finally, enjoy your self closing Elementor Off Canvas with Anchor links!
I hope you have enjoyed this tutorial.
Cheers!
10 Responses
hello! Thank you very much for your code. I have a problem... every time I click the anchor link it works, but when the offcanvas component disappears, the page goes back to the top. Would you know how to solve it?
Hey Daniel!
Could you share your URL with me where this is happening?
Thank you also for this solution. Unfortunately, I have exactly the same problem as Daniel.
Could you share your URL with me where this is happening?
Sorry this is a bug from Elementor. The simple fix is to make the header sticky, then it will work as intended.
For headers that are not sticky, hopefully Elementor will fix the way they coded this soon!
Is there a way to close all off canvas? I did a nesting thing and want the x to close all...
Hey Shelley!
Try this code instead of the one provided in the tutorial, let me know if it works!
Cheers!
Greetings Shelley!
Did the code work for you?
Yes thank you! Sorry for late reply - we got it all working and is a great little hack 🙂
Hello, I need help, I am using elementor menu mini cart and inside min cart i have added 'continue shopping' button which should just close the mini cart (just like when someone click on cross and it close), but i cannot find any solution or snippet, So is there a way to close minic cart onclick button.?