E
E
Elios2014-08-18 13:53:51
User navigation
Elios, 2014-08-18 13:53:51

How to create a horizontal menu that appears after scrolling?

Interested in not a simple moment, in fact the menu should appear after scrolling a certain number of pixels. But there is one thing, it should be formed only after scrolling, and should not be shown on the site before. When scrolling up, it should be deleted completely, because there is already a menu at the top. Unfortunately, I can not show an example, because I simply did not find it.
The script I use is this:

$(function () {
 
    $(window).scroll(function(event) {
        if($(this).scrollTop() > 150) {
        $("#menu").fadeIn();
        $("#menu").addClass('fixed')
    }
    else {
        $("#menu").removeClass('fixed')
    }
    });
 
});

It follows that when scrolling to 150px, the menu will be fixed.
How to make on the basis of this script that the menu would be formed when scrolling ??
People do not kick much if you did not clearly describe the problem)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yuri Lobanov, 2014-08-18
@Elios

Why do you need a new menu? When scrolling, add a new class to your menu, exclude it from the flow using fixed, and so that the content does not leave the menu height up, use margin-top.
And in the new class, redefine your menu as you want, at least the appearance, at least hide some items.
Here is an example I wrote for a similar question.
codepen.io/iiil/pen/InDbp

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question