How to make a smooth menu capture?

  • 0
    Hello, I need help with the menu block, search and other buttons. When scrolling to the bottom, it should "stick" from the position where it is located, and during the first scrolls to the bottom, it jumps to the top of the browser and back again. Here's what's available: link where you can look at example and the js code itself
    $(window).scroll(function() {
          if ($(window).scrollTop() > elementPosition.top) {
            $('.panel-nav').addClass("fixed");
            $("body").css({
              "paddingTop": "80"
            })
          } else {
            $('.panel-nav').removeClass("fixed");
            $("body").css({
              "paddingTop": "80"
            })
          }
        });
    JavaScript Thomas Walker, Jun 7, 2020

  • 1 Answers
  • 0
    You don't need js here. Unless, of course, IE support is required.

    .panel-nav {
    position: sticky;
    top: 0;
    }
    Nathan Marks

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!