Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Menu navigation disappear at width

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #180972
    Jtwa11
    Participant

    I’m trying to make my navigation to disappear at < 750px in width. Once it collapses, I want to make it reappear with a click.

    Here is my codepen

    http://codepen.io/Jtwa/pen/kIpsj

    My problem, if i make it disappear at <750, it stays disappeared at >750

    #180974
    nixnerd
    Participant

    Can I ask why you’re doing this in JS? Why not media queries in CSS?

    #180981
    nixnerd
    Participant

    Shit. Sorry. I didn’t actually look at your code. I thought this was just a standard media query.

    The problem is your function only fires when the logo is clicked. So, you probably need a function to hide/show your slideToggle on window resize.

    #180984
    __
    Participant

    jQuery’s .slideToggle method animates the height of the element, and then sets display: none. You can add another media query to make sure the display is set back to block when wider than 750px.

    @media (min-width:751px){
      nav ul{ display:block !important; }
    }
    

    codepen

    On an unrelated note, why are you passing "show" to slideToggle? Looking at the docs, seems the only string arguments it expects are easing or duration, and “show” doesn’t mean anything in either case.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.