L
L
lilandre22017-05-29 22:26:48
css
lilandre2, 2017-05-29 22:26:48

How to fix top menu in jooml when scrolling down?

I work with the site test.vip-photo.com.ua/index.php/ru .
It is necessary that when scrolling down, the top menu id="mainmenu" was fixed at the top. I have included jquery.

$document = &JFactory::getDocument();
$document->addScript( '/media/system/js/myscript.js' );
$document->addScript( '/media/system/js/jquery-3.2.1.min.js' );


Tested - works. Connected java script file myscript.js
jQuery(function($) {
        $(window).scroll(function(){
            if($(this).scrollTop()>140){
                $('#mainmenu').addClass('fixed');
            }
            else if ($(this).scrollTop()<140){
                $('#mainmenu').removeClass('fixed');
            }
        });
    });

and also added css style
#mainmenu.fixed{
      position: fixed;
      top: 0;
      width: 100%;
      background: rgba(239, 5, 5, 0.95);
  }
.I can not understand why the menu is not fixed when scrolling.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Nameless08, 2017-06-06
@lilandre2

Already solved the problem? Because I look at it works prntscr.com/fgf5f8

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question