Scrolling a page using the keyboard (PgUp / PgDown, Space) sometimes becomes difficult if there are elements with fixed positions at the top of the page, for example. navigation bars: content that was not visible at the bottom of the viewport can be hidden by fixed elements after scrolling.
How to solve this problem? Do browsers calculate how far they should scroll? I observed different types of behavior for different browsers, as well as for the same browsers on different pages (for example, Firefox leaves about 80 pixels of old content at http://www.sueddeutsche.de/ , but much less http: //www.taz .de . Chrome leaves much more content.).
This is generally a problem, i.e. Does anyone near me use the keyboard to scroll a webpage? Do you know any statistics?
To illustrate the problem, I created a script: https://jsfiddle.net/x7hj8c4m/ Try scrolling through the contents using Space in Firefox. A fixed item will span text that was not yet visible before scrolling. If you add left: 0 , it will work.
javascript html css browser
Christian
source share