The World’s Largest Online Community for Developers

'; javascript - Slider nav abruptly shows up when reaching smaller breakpoints - LavOzs.Com

I have built a hamburger menu with smooth transition to make it visually appealing. Everything is working fine and I was able to do this with javascript. However, once the browser reaches certain breakpoints where the hamburger menu displays, the slider nav abruptly shows up then closes.

CSS code:

    body {
        overflow-x: hidden;
    .nav-links {
        position: absolute;
        right: 0;
        height: 92vh;
        top: 8vh;
        background-color: #54976B;
        flex-direction: column;
        justify-content: space-evenly;
        align-items: center;
        width: 30%;
        transform: translateX(100%);
        transition: transform 0.5s ease-in;

            li {
                opacity: 0;


    .burger {
        display: block;

} ```

### Then this is my active class so the transform occurs when the hamburger menu is being clicked
``` .nav-active {
    transform: translateX(0);


And this is my JavaScript code:

    const burger = document.querySelector('.burger')
    const nav = document.querySelector('.nav-links')

    burger.addEventListener('click', () => {