Nav disappears after resize

2019-09-15 17:20发布

Site in question: http://www.mtthwbsh.com

I'm building a collapsable nav for this site and have noticed that after it collapses, if you expand and retract it and enlarge the window again the nav disappears. I tried changing the display to block at my media queries but I think the jQuery is overriding it. Any idea what's causing this?

Also, I'd like the arrow to rotate 180 degrees when clicked, how would I target this? My jQuery is as follows:

/* toggle nav */
$("#menu-icon").on("click", function(){
$(".nav").slideToggle();
$(this).toggleClass("active");
});

2条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-09-15 17:46

$(".nav").slideToggle(); appears to be leaving the nav in a display:none; state. When you set tried to set the display:block; in your media query did you use !important?

Edit

If your screen size less than 570px needs to be toggled, then you need to make sure that at any size above 570px it will be set in CSS to display:block;

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

This should adequately override the display property.

查看更多
Emotional °昔
3楼-- · 2019-09-15 17:55

In style.css, line no. 1015, media queries used for max-width:820px

@media (max-width: 820px)

Check these images, Visible nav, Hidden nav (check css inspector)

查看更多
登录 后发表回答