Forums

Give help. Get help.

  • # November 7, 2018 at 8:34 pm

    I want to remove a class that stacks menu items, after a hamburger-icon has been clicked. Then, when the window is resized over 500px (or so) the items should be floated again.

    I have that menu-open/close-thing running, but not the resize function.

    I guess, I need an event listener that listens to ”window.resize”, then need to get something like 500px in there with something like ”innerWidth” and then need to do something like ”myElement.classList.remove(”my-class”)”. But I just don’t get the syntax together.

    Please take a look at my Codepen

    # November 7, 2018 at 10:14 pm

    Give this a try instead:

    window.addEventListener("resize", function() {
      if (window.innerWidth < 500) resize.classList.remove("nav--is-open");
    });
    

    It’s not the nav that resizes but the screen itself.

    # November 8, 2018 at 8:41 am

    Ahhh, I get it! Thank you so much!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

icon-anchoricon-closeicon-emailicon-linkicon-logo-staricon-menuicon-nav-guideicon-searchicon-staricon-tag