Skip to main content

Forums

This topic contains 2 replies, has 2 voices, and was last updated by  Zander 4 months, 1 week ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #278573

    Zander
    Participant

    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

    #278574

    Shikkediel
    Participant

    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.

    #278581

    Zander
    Participant

    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-link icon-logo-star icon-search icon-star