I see on many sites like this that when you start scrolling the Menu goes to the top and when it is in top it stays in its place of origin (As if it were floating). How do I apply this effect?
I see on many sites like this that when you start scrolling the Menu goes to the top and when it is in top it stays in its place of origin (As if it were floating). How do I apply this effect?
A simple way to add this effect is through JavaScript, see the example below:
$(window).bind('scroll', function () {
if ($(window).scrollTop() > 50) {
$('.menu').addClass('fixed');
} else {
$('.menu').removeClass('fixed');
}
});
This response is based on a response in StackOverflow International. See the example in jsfiddle .