Articles on: Page Editor

How to keep a MENU FIXED on the screen (Sticky Menu)

To keep the menu of your page fixed on the screen while visitors browse your site, follow the tutorial below:


  1. Log in to your GreatPages account and access the page editor;



  1. Go to the gear icon in the top right corner of the screen;



  1. Go to "Javascript & CSS" and click on "Adicionar código";




  1. Give it a name, check the "Funcionamento" option and add the entire code below into the text field;


<script>
(function () {
var primeiroBloco = document.querySelector('#site .gpc-b:first-of-type');
if (!primeiroBloco) return;

var segundoBloco = primeiroBloco.nextElementSibling;

function fixarMenu() {
if ((window.pageYOffset || window.scrollY) > 0) {
primeiroBloco.style.position = 'fixed';
primeiroBloco.style.top = '0';
primeiroBloco.style.left = '0';
primeiroBloco.style.width = '100%';
primeiroBloco.style.zIndex = '9999999';

if (segundoBloco) {
segundoBloco.style.marginTop = primeiroBloco.offsetHeight + 'px';
}
} else {
primeiroBloco.style.position = '';
primeiroBloco.style.zIndex = '';

if (segundoBloco) {
segundoBloco.style.marginTop = '0px';
}
}
}

window.addEventListener('scroll', fixarMenu, false);
fixarMenu();
})();
</script>



  1. After that, click on "Salvar".


Keep in mind that this code will only keep the first block fixed on the screen. If you need another block to stay fixed, follow the tutorial below, or contact our team on Chat.


How to keep a SPECIFIC BLOCK FIXED on the screen — https://ajuda.greatsoftwares.com.br/pt-br/article/como-manter-um-bloco-especifico-fixo-na-tela-36zpp/

Updated on: 08/01/2026

Was this article helpful?

Share your feedback

Cancel

Thank you!