Jquery addClass applies but does not give me the result

Asked

Viewed 31 times

0

Good morning, I’m having a problem, I’m trying to make an effect for my menu, when the user passes 200 in the scroll the menu increases using the height: 85px;, when scroll up it removes the class I created for height: 85px; letting another class in, but I’m not able to apply on the site, because I made the code, when I roll the scroll it adds the class looking at the element inspecte but it does not bring me the result that in case it would increase the heigth from the menu, I’m using the Sass is that causing me trouble? follows the code below:

movimenta.js:

$(function () {
    $('header').show();
    $(window).scroll(function () {
        if ($(this).scrollTop() > 200) {
            $('header').addClass('header-efeito');
        } else {
            $('header').removeClass('header-efeito');
        }
    });
});

_header.scss:

    .header-efeito {
        header {
            max-height: none;
            height: 130px;
        }
    }


/* voltar como estava */
.main {
    header{
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        z-index: 10;
        max-height: 85px;
        overflow: hidden;
        background: $white;
    }
}

Someone could help me... Thank you

  • Sometimes Jquery(even if javascript) is not able to interpret Sass, makes a normal css code and tries to apply the efeitoss to see!

1 answer

0

Stack people manage to solve the problem...

was declaring the class and the header being that it did not need

wrong code:

.header-efeito {
      header{
        height: 130px !important;
   }
}

sure code:

.header-efeito {

        height: 130px !important;
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.