Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

118
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!