Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

127
Visualizações
Can I change the amount that pagedown/pageup scrolls the page, to avoid some content being lost behind a fixed header?

I recently learnt about :target::before{content:'';display:block;height:--fixedHeaderHeight} which enables fragments to scroll into position without being hidden by a tall fixed header. I.e. if the header is 200px high, the element with the ID specified in the URL will appear just below that, rather than hidden behind it.

I have a similar problem in my admin system of pgup/pgdn though. I regularly page up and down through a screen, and some items end up being hidden behind the fixed header. I.e. something that's just off the bottom of the first "page" and ends up at the top of the second "page" gets hidden behind the header, and is never seen.

Is there a similar CSS (or JS) trick to change the amount of content that gets scrolled with each press of pgup/pgdn, or am I out of luck?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Here's what I've gone with:

document.addEventListener('keydown', function(e) {
    if(e.key === 'PageUp' || e.key === 'PageDown') {
        e.preventDefault();

        const doc = document.documentElement;

        const left = doc.scrollLeft;
        const top  = doc.scrollTop;

        // standard offset in Chrome is 30px, and the site header is 104px
        const delta = window.innerHeight - 134;


        (e.key === 'PageUp') ? window.scrollTo(left, top - delta)
                             : window.scrollTo(left, top + delta);
    }
});
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda