- This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
Viewing 4 posts - 1 through 4 (of 4 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › Menu navigation disappear at width
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
Can I ask why you’re doing this in JS? Why not media queries in CSS?
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.
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; }
}
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.