A
A
adil162019-10-18 18:41:08
User navigation
adil16, 2019-10-18 18:41:08

How to make the site menu fixed?

I specify the following values ​​for classes in css styles:

position: fixed;
    left:0;
    top: 0;
    width: 100%;
    z-index: 999;
    max-width:0px;
    overflow:visible;
    background-color: #f69d01;
    margin: 0;
    transition: 0.25s ease-in;
    -webkit-transition: 0.25s ease-in;
    -moz-transition: 0.25s ease-in;
    -ms-transition: 0.25s ease-in;

the menu is not fixed when scrolling. menu code in html:
<section class="in_menu_wrapper ">
  <div class="container">
    <div class="row ">
      <div class="col-lg-3 col-md-3 col-sm-3 col-xs-6">
        <div class="in_logo ">
          <a href="index.html">
            <img src="images/logo.png" width="265" height="52" alt="">
          </a>
        </div>
      </div>
      <div class="col-lg-9 col-md-9 col-sm-9 col-xs-6">
        <nav class="navbar">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          
        
          <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <div class="in_menu nav navbar-nav">
              <ul>
                <li ><a href="index.html">Главная</a></li>
                <li ><a href="#company">О Нас</a></li>
                <li ><a href="#uslugi">Услуги</a></li>
                <li ><a href="#tarif">Тарифы</a></li>
                <li ><a href="#otziv">Отзывы</a></li>
                <li ><a href="#contactus">Контакты</a></li>
                
              </ul>
              
            </div>
          </div>
        </nav>
      </div>
    </div>
  </div>
</section>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Pashenka, 2019-10-18
@like-a-boss

take awaymax-width:0px;

$(function(){
    $(window).scroll(function() {
        if($(this).scrollTop() >= 66) {
            $('.in_menu_wrapper').addClass('stickytop');
        } else{
            $('.in_menu_wrapper').removeClass('stickytop');
        }
    });
});

.stickytop {
    position:fixed;
    top:0;
    z-index: 2;
}

A
adil16, 2019-10-18
@adil16

almost figured it out, another position was indicated in another place, but now the block that was on top of the menu was blocked

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question