1

I want add a sticky menu (Floating) on top of pages when the page scroll down but the top menu stay on top of browsers and mobile devices.

How to achieve this result in Magento 1.9.x?

1 Answer 1

6

Welcome to Magento.SE!

While this is not necessarily a Magento question (it's really more a CSS/jQuery question) there is a particular way that I would handle this in CE1.9+

In your own custom styles.css file:

.sticky { position: fixed; top: 0; z-index: 9999; } 

And now in a custom javascript I would include the following:

(function($, w){ $(function(){ var $nav = $('#header-nav'); var stickyNavTop = $nav.offset().top; var stickyNav = function(){ var scrollTop = $(w).scrollTop(); if (scrollTop > stickyNavTop) { $nav.addClass('sticky'); } else { $nav.removeClass('sticky'); } }; $(w).scroll(function() { stickyNav(); }); stickyNav(); }); })($j, window); 
1
  • How can we add easing to this? Commented Jul 13, 2015 at 15:41

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.