S
S
Sergey171220022018-05-02 17:44:06
CMS
Sergey17122002, 2018-05-02 17:44:06

How to pin a menu?

How can I pin the menu so that it stays visible on top when swiping?
cosmofest.kvantorium48.ru

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladislav Boychenko, 2018-05-02
@vladislav_boychenko

var navPos = $('#main-navigation').offset().top;
  $(window).scroll(function(){
    if ($(this).scrollTop()>=navPos) {
      $('#main-navigation').addClass('fixed');
    } else {
      $('#main-navigation').removeClass('fixed');
    }
  });

#main-navigation.fixed {
  position: fixed;
  top: 0; 
  left: 0; 
  right: 0; 
  z-index: 10; 
  margin-top: 0;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question