移动版本影响桌面

时间:2017-11-30 18:57:13

标签: javascript css

我有这个javascript切换移动版本中的下拉导航菜单。然后,当我将浏览器的大小调整为桌面大小时,导航就搞砸了。如何在调整浏览器大小后返回默认样式?谢谢

icon.addEventListener("click", showMenu);
let executed = false;

function showMenu() {

if (executed == false) {
    nav.style.height = "0px";
    executed = true;

}
console.log(nav.style.height);
if (nav.style.height === "0px"){ //Want height only to be changed for mobile
nav.style.height = "460px";
} else {
    nav.style.height = "0px";
}
}    

0 个答案:

没有答案