我有一个汉堡包菜单,当我“点击”它时,一个菜单就滑了进来。 我试着做了大部分,但当我点击菜单时,滑入菜单会停留一秒钟,然后返回。 我怎样才能使菜单留下来呢?
#navigationWrap {
position: fixed;
top: 0;
left: -1000px; /* left: 0; */
width: 710px;
height: 100vh;
background: grey;
null
*{
margin: 0px;
padding: 0px;
box-sizing: border-box;
}
body{
background: #FCF7F0;
}
header{
display: flex;
width: 90%;
margin: auto;
height: 10vh;
}
.navbar{
flex: 1;
text-align: left;
padding-top: 60px;
color: black;
cursor: pointer;
}
.close{
flex: 1;
/* background: lightsalmon; */
text-align: right;
padding-top: 60px;
color: black;
}
.fa {
font-size: 68px !important; /*size of fa icons*/
}
.presentation{
display: flex;
margin: auto;
}
#navigationWrap {
position: fixed;
top: 0;
left: -1000px; /* left: 0; */
width: 710px;
height: 100vh;
background: grey;
transition: .5s;
padding: 20px;
text-align: center;
box-sizing: border-box;
z-index: 10;
}
.navbar:active ~ #navigationWrap {
left: 0;
transition: .1s;
}
.close_container{
display: block;
text-align: left;
position: absolute;
top: 60px;
left: 60px;
color: white;
z-index: 15;
cursor: pointer;
}
.nav-links{
justify-content: space-around;
list-style: none;
padding: 150px 0px 100px 0px;
}
.nav-link{
text-decoration: none;
color: white;
font-size: 50px;
line-height: 80pt;
}
<head>
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
</head>
<body>
<header>
<div class="navbar" title="menu">
<i class="fa fa-bars" aria-hidden="true"></i>
</div>
<div class="close">
<i class="fa fa-times" aria-hidden="true"></i>
</div>
<div id="navigationWrap" class="navigationWrap">
<div class="container">
<div class="close_container">
<i class="fa fa-times" aria-hidden="true"></i>
</div>
<nav>
<ul class="nav-links">
<li><a href="#" class="nav-link">Home</a></li>
<li><a href="#" class="nav-link">Services</a></li>
<li><a href="#" class="nav-link">About</a></li>
<li><a href="#" class="nav-link">Contact</a></li>
</ul>
</nav>
</div>
</div>
</header>
<main>
<section class="presentation">
</section>
</main>
</body>
null
transition: .5s;
padding: 20px;
text-align: center;
box-sizing: border-box;
z-index: 10;
}
.navbar:active ~ #navigationWrap {
left: 0;
transition: .1s;
}
有人能看看我的问题,看看我该如何解决它吗? 提前谢谢你。
如果您想使用带有hamburger按钮的导航菜单,则需要使用,当选中该菜单时,该菜单将展开。
null
/* You can't modify checkbox so hide it */
#hamburger-checkbox {
display: none;
}
/* Use label instead */
.hamburger {
font-size: 30px;
position: absolute;
}
/* Use :checked to indicate when it's checked */
#hamburger-checkbox:checked~.nav {
width: 100%;
transition: 2s ease;
}
.nav {
width: 0;
height: 100px;
background: orange;
transition: 2s ease;
}
<header>
<input type="checkbox" id="hamburger-checkbox">
<label class="hamburger" for="hamburger-checkbox">☰</label>
<nav class="nav">
<!-- rest of the nav here -->
</nav>
</header>