Sticky navigation element jumps during scroll

后端 未结 4 1025

In Firefox especially, I\'ve run into an issue I can\'t figure out how to fix.

On the following page, when scrolling down the page jumps several times - mainly on s

4条回答
  •  别那么骄傲
    2020-12-23 19:40

    After seeing you asking for help on another answer, I will try and explain more clearly for you.

    The Problem

    Your problem is when you add position:fixed to the navigation bar, it removes it from its place and sticks it at the top of the page. This is why the rest of your content jumps up - because the navigation bar is not where it was anymore.

    How To Fix

    You can get around this by wrapping your navigation element in a new div - let's call it nav-wrapper - and set its height to the same as your navigation element. These are known as placeholder elements. This new wrapper and your original navigation bar must always be the same height for the 'jump' to disappear.

     
         
     
    热议问题