这是我在CodePen.Below上的current project是我的代码。对不起,太长了。我试图通过不添加动画来简化它。为什么我的缩进菜单不弹出?
欲望的影响是,当您单击菜单图标时,第一个导航栏滑入,第二个导航栏滑过。但我不知道我的第二个导航栏在哪里,它没有出现。
//This function retracts the menu bar with the menu icon and expand the menu bar with close icon.
function open(){
document.getElementById("openNav").style.width = "0px";
document.getElementById("closeNav").style.width = "20%";
}
//This thing does the opposite of the above function
function close(){
document.getElementById("openNav").style.width = "20%";
document.getElementById("closeNav").style.width = "0px";
}
*{
padding:0;
margin:0;
}
html, body{
height:100%;
width:100%;
}
/*First nav bar of the two. You press the menu icon, this bar slides in and the second nav bar slides out.*/
.openNav{
height:100%;
width:20%;
background:#111;
}
.openBox{
width:100%;
box-sizing:border-box;
padding:calc((100% - 50px)/2);
position:relative;
bottom:15px;
}
.open{
font-size:50px;
color: #818181;
}
/*Second nav bar with a close button. You press the close button, the bar slides in and the first nav bar slides out.*/
.closeNav{
height:100%;
width:20%;
background:#111;
}
.closeBox{
width:100%;
box-sizing:border-box;
padding:calc((100% - 50px)/2);
position:relative;
bottom:15px;
}
.close{
font-size:50px;
color: #818181;
}
<div class='openNav' id='openNav'>
<div class='openBox'>
<div class='open' onclick='open()'>☰</div>
</div>
</div>
<div class='closeNav' id='closeNav'>
<div class='closeBox'>
<div class='close' onclick='close()'>×</div>
</div>
</div>
第二个导航栏是在底部? – AirNoir