• Как сделать чтоб меню при скролинге пряталось?

    @pacificregmi
    Technology content writer and developer
    To hide the menu when scrolling a webpage, you can use JavaScript to detect the scroll event and add a class to the menu element that hides it when the page is scrolled. Here is an example of how you can do this:

    window.onscroll = function() {
      var menu = document.getElementById("menu");
      if (document.body.scrollTop > 50 || document.documentElement.scrollTop > 50) {
        menu.classList.add("hidden");
      } else {
        menu.classList.remove("hidden");
      }
    };


    You will also need to add a style for the "hidden" class that hides the menu element. For example:

    .hidden {
      display: none;
    }
    Ответ написан
    Комментировать