Capita anche a voi di avere delle ancore nel sito che però si nascondono sotto al menu? Ecco la soluzione da inserire nelle vostre pagine:
<script type="text/javascript">
document.addEventListener('click', function(e) {
const anchor = e.target.closest('.elementor-button');
if (anchor && anchor.getAttribute('href').startsWith("#")) {
e.preventDefault();
e.stopPropagation(); // Blocca la propagazione dell'evento
const targetID = anchor.getAttribute('href').substring(1);
const targetElement = document.getElementById(targetID);
if (targetElement) {
const yOffset = -100;
const y = targetElement.getBoundingClientRect().top + window.pageYOffset + yOffset;
window.scrollTo({
top: y,
behavior: 'smooth'
});
}
}
}, true);
</script>

Lascia un commento